iframe不显示图片问题

weidu23 2013-08-26 10:51:36
我的代码是这样的:

---------index.jsp<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
document.getElementById("if").width =screen.availWidth;
</script>
</head>

<body>
<center>
<iframe id="if" frameborder="0" src="<%=basePath %>mainVisual/mainFrame.jsp"></iframe>
</center>
</body>
</html>


然后这是mainFrame.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
</style>
</head>
<frameset rows="15%,*" frameborder="no" border="0">
<frame scrolling="no" src="<%=basePath %>mainVisual/top.jsp" noresize="noresize"/>
<frame src="<%=basePath %>mainVisual/mainForm/mf_Frame.jsp"/>
</frameset>
</html>


然后是top.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>

<body>
<img alt="欢迎来到W3copy" src="<%=basePath%>W3Images/toplogo.jpg">
</body>
</html>


----------------------分割线---------------------
当我直接写上http://localhost:8080/W3copy/mainVisual/mainFrame.jsp时,
能否正常输出图片!

但是,当我http://localhost:8080/W3copy/是,图片好像被压缩了一样,只显示一点点。

请问,这是怎么回事,该怎么解决呢 ?

注:
1、我的web.xml默认了index.html:<welcome-file>index.jsp</welcome-file>
2、希望回答者能够用代码交流,这样更易理解!谢谢
...全文
432 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
SpringHiSay 2013-08-30
  • 打赏
  • 举报
回复
图片都写成绝对路径试下 <img alt="欢迎来到W3copy" src="/W3Images/..">
暖暖猫 2013-08-30
  • 打赏
  • 举报
回复
ceshi1.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<center>
          <iframe src="ceshi2.html" width="100%" height="400" scrolling="no" frameborder="0"></iframe>
    </center>
</body>
</html>
ceshi2.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
 <frameset rows="15%,*" cols="*">
      <frame scrolling="no" src="ceshi3.html" noresize="noresize"/>
      <frame src="ceshi4.html"/>
  </frameset>
</html>
ceshi3.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<img alt="欢迎来到W3copy" src="2012.jpg">
</body>
</html>
ceshi4.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
下方显示
</body>
</html>
weidu23 2013-08-30
  • 打赏
  • 举报
回复
引用 1 楼 weidu23 的回复:
[quote=引用 楼主 weidu23 ]......
我猜测问题出在iframe,所以我试图再javascript里面给iframe设置全屏大小,可是怎么设我不会,上面自己写的那个也不知道有没有错![/quote] 自己在顶一下
weidu23 2013-08-26
  • 打赏
  • 举报
回复
引用 楼主 weidu23
......
我猜测问题出在iframe,所以我试图再javascript里面给iframe设置全屏大小,可是怎么设我不会,上面自己写的那个也不知道有没有错!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧