假设有A.htm、B.htm两页,A.htm:
<div id=aaa></div><iframe width=0 height=0src=b.htm></iframe>
B.htm:
<script>parent.aaa.innerHTML='test!'</script>那我如何在A页面刷新B页面呢?
<div id=aaa></div><iframe width=0 height=0src=b.htm></iframe>
B.htm:
<script>parent.aaa.innerHTML='test!'</script>那我如何在A页面刷新B页面呢?
解决方案 »
- 高手们求救
- 计数器的详细设计说明怎么写?
- struts1的HTML<link>标签为什么不显示?
- 数据库问题
- 急,关于B/S结构设计
- 我在文本框中输入了几段文字,然后存入数据库,可是当我取出来的时候却变成了一段,这如何解决呢?!请大虾指点!
- jive安装过程中的jive.license文件,怎么总是说有错误呢?
- 请教,关于用bean编写连接池的问题!
- 向各位请教 ,关于我的 JAVA BEANS 怎样在 JRUN 即 (JSP)中调用!
- 求教 OpenSessionInViewFilter 的解决方案
- 【java过滤器】新手求问一句话什么意思?
- 请大家帮我看一下,运行Hibernate时报异常,该怎么处理?谢谢啦!
document.all.ifrmname.document.location.reload()定义一个ID
ifrmid.window.location.reload()
<td width="100">用户名</td>
<td width="150"><input type="text" name="username" id="username" size="20"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="password" id="password" size="21"></td>
</tr>
<tr>
<td>验证码</td>
<td><input type="text" id="Verification" name="Verification" value="" size="2"> <span id="VerCode"></span><iframe width=0 height=0 id="vc" name="vc" src=image.jsp></iframe></br><a href="" onclick="reload()">换一张</a></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登陆"><input type="reset" value="重置"></td>
</tr>image页面:
<script language="JavaScript">
function reloadcode(){
parent.VerCode.innerHTML = "<input type=\"image\" src=\"VerficationServlet\" disabled>";
}
</script>
</head>
<body onload="reloadcode()">
</body>
在子页面里通过js往父页面传递图片的path,在父页面里顶一个隐藏域来接收这个对应的路径,这样就能是实现图片浏览了 <c:if test="${!empty(requestScope.path)}">
<script>
parent.document.getElementById("path").value="${requestScope.path}";
parent.document.getElementById("view").innerHTML="<img src=\"${pageContext.request.contextPath}/${requestScope.path}\" height='200 width='200'/> "
</script>
</c:if>[code=text]
<tr>
<td>
图片
</td>
<td>
<iframe
src="${pageContext.request.contextPath }/upload.jsp?path=${requestScope.product.path}"
width="100%" height="25" marginheight="0" marginwidth="0"
scrolling="no" frameborder="0"></iframe>
</td>
</tr>
<tr>
<td>
浏览
</td>
<td id="view">
<c:if test="${empty(requestScope.product.path )}">
</c:if> <c:if test="${!empty(requestScope.product.path)}">
<img
src="${pageContext.request.contextPath }/${requestScope.product.path}"
width="200" height="200" />
</c:if> </td>
</tr>[/code]
然后A页面代码:<%@ 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>
<base href="<%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script language="JavaScript">
function reload(){
vc.window.location.reload();
}
</script>
</head>
<body>
<table>
<tr>
<td>验证码</td>
<td><input type="text" id="Verification" name="Verification" value="" size="2"> <span id="VerCode"></span><iframe width=0 height=0 id="vc" name="vc" src=b.jsp></iframe></br><a href="" onclick="reload()">换一张</a></td>
</tr>
</table>
</body>
</html>然后B.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>
<base href="<%=basePath%>">
<title>My JSP 'image.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script language="JavaScript">
function reloadcode(){
parent.VerCode.innerHTML = "<input type=\"image\" src=\"VerficationServlet\" disabled>";
}
</script>
</head>
<body onload="reloadcode()">
</body>
</html>你看下有什么问题吗?
我之前也碰到类似的问题,可以看看我这个帖子,希望对你有帮助!