12月26日iframe执行

我今天的疑问:

1.window.frames["iframesubmit"].document.getElementById("P_KeyId").value;为什么iframe里还能点document,iframe里就没写子元素。

答:千万要仔细!iframe标签里虽然没有子元素,但是iframe如果有src属性,那么这个src指向的页面就相当于iframe里的子元素。iframe能取到所指向页面里的所有元素节点。

2.在gdfAction.jsp中为什么执行完添加,修改操作后,执行下面代码的out.println("alert(window.top.opener.frames[\"iframesubmit\"].location);");

out.println("window.top.opener.location.reload();");

一样.

答:首先我需要搞明白window.top.opener取到的是哪个窗口,其实是gdfMain.jsp窗口而不是gdfList.jsp窗口.然后再看下面的图,即可明白.

     window.top.opener表示当前窗口的最顶层的窗口a,然后再获取a的父窗口.

     执行红色代码表示刷新的是gdfMain.jsp中的name=iframesubmit的iframe组件里的内容,因为iframe组件的src指向了一个gdfList.jsp,所以说白了就是在iframe里加载gdfList.jsp页面.

   执行绿色代码表示刷新整个gdfMain.jsp页面,这其中就包括了ifream组件以及iframe组件指向的gdfList.jsp页面,(造成一些不必要的刷新)

out.println("<script>");
if(I_OpMode.equals("添加")){
	out.println("alert('"+I_OpMode+"成功');");
	out.println("window.top.opener.frames[\"iframesubmit\"].location.reload();");
	out.println("window.top.close();");
}else if(I_OpMode.equals("修改")){
	/* out.println("alert(window.location);");
	out.println("alert(window.top.location.host);");
	out.println("alert(window.top.opener.location.href);");
	out.println("alert(window.top.opener.location);");//当前窗口的父窗口的URL信息 */
	out.println("alert(window.top.opener.location);");
	out.println("alert(window.top.opener.frames[\"iframesubmit\"].location);"); 
	out.println("alert('"+I_OpMode+"成功');");
	out.println("window.top.opener.location.reload();");
	out.println("window.top.close();");
}else if(I_OpMode.equals("删除")){
	out.println("alert('"+I_OpMode+"成功');");
	out.println("window.parent.location.reload();");
}
out.println("</script>");


1.这张页面是gdfMain.jsp,这个页面分上下两个部分,按钮这一行是分割线

下面列表部分的代码如下:

<td valign="top" height="100%" >
     <iframe name="iframesubmit" id="iframesubmit" src="gdfList.jsp?start=1&pagecount=50&endrow=50" width="100%" height="100%" framespacing="0" border="0" frameborder="no"></iframe>
</td>
表示这个iframe里是引用另一个gdfList.jsp页面.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值