新人弱弱的问下局部刷新问题~~

Inuyashazc 2013-02-20 10:03:10
假设有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页面呢?
...全文
322 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Inuyashazc 2013-02-25
  • 打赏
  • 举报
回复
引用 12 楼 errrry 的回复:
http://bbs.csdn.net/topics/390359666 我之前也碰到类似的问题,可以看看我这个帖子,希望对你有帮助!
非常好!瞬间解决了~但是原因我还是不太清楚,跟我这个有什么区别呢。。。
evang_shot 2013-02-25
  • 打赏
  • 举报
回复
http://bbs.csdn.net/topics/390359666 我之前也碰到类似的问题,可以看看我这个帖子,希望对你有帮助!
Inuyashazc 2013-02-25
  • 打赏
  • 举报
回复
大神来帮下吧~~~~
Inuyashazc 2013-02-21
  • 打赏
  • 举报
回复
大神们求助下~~
yu271400 2013-02-20
  • 打赏
  • 举报
回复
ajax,或者jquery解决吧,很简单的。
Maakey 2013-02-20
  • 打赏
  • 举报
回复
楼主解决了,记得把答案贴出来,求解。。。。
Inuyashazc 2013-02-20
  • 打赏
  • 举报
回复
引用 1 楼 zh919919 的回复:
给你的iframe定义一个name document.frames('ifrmname').location.reload() document.all.ifrmname.document.location.reload() 定义一个ID ifrmid.window.location.reload()
谢谢这个方法不错~~但是还有个问题~~我发现这样点击刷新还是全页面刷新额~~为什么不是局部刷新的?
<tr>
                        <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>
zh919919 2013-02-20
  • 打赏
  • 举报
回复
给你的iframe定义一个name document.frames('ifrmname').location.reload() document.all.ifrmname.document.location.reload() 定义一个ID ifrmid.window.location.reload()
Inuyashazc 2013-02-20
  • 打赏
  • 举报
回复
引用 7 楼 ljc19901124 的回复:
大体思路了解了 实现起来就简单了
我有点不太理解~~~~~能这样嘛~我写个简单的你看看哪里不对? 有一个登陆JSP就叫A.jsp还有个图片的jsp就叫B.jsp好了 然后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>

你看下有什么问题吗?
爱T 2013-02-20
  • 打赏
  • 举报
回复
嗯 想要用ajax来实现这些,可以在js里用ajax控制啊,包括图片浏览也可以在ajax返回的data路径结果在js里直接去处理
爱T 2013-02-20
  • 打赏
  • 举报
回复
大体思路了解了 实现起来就简单了
爱T 2013-02-20
  • 打赏
  • 举报
回复
引用 5 楼 zhce001 的回复:
引用 4 楼 yu271400 的回复: ajax,或者jquery解决吧,很简单的。 ajax不太清楚如何传图片出来~~~
在子页面里通过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]
Inuyashazc 2013-02-20
  • 打赏
  • 举报
回复
引用 4 楼 yu271400 的回复:
ajax,或者jquery解决吧,很简单的。
ajax不太清楚如何传图片出来~~~

81,094

社区成员

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

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