window.opener.location.reload() and href()的区别 弹出页修改后刷新父窗体 .
来源:互联网 发布:西裤材质 知乎 编辑:程序博客网 时间:2024/05/01 06:36
2个方法都是刷新父窗口,但是其中还是有奥妙的哦。
window.opener.location.reload();这个方法在强迫父窗口的时候,在有些IE浏览器(比如安全设置高)的情况下,会弹出一个确认对话框,提示是不是要重新再刷新一次页面,这可是比较郁闷的事情哦,我后来把这个方法替换成了window.opener.location.href=window.opener.location.href;
就不会出现那样的问题了。
window.opener其实是指本窗口的父窗口,比如,one.jsp 通过popupwindow打开了two.jsp,哪么在two.jsp里面的window.opener就是指one.jsp,所以在two.jsp里面完全可以用window.opener调用任何一个one.jsp里面的方法,实现one.jsp和two.jsp的交互。
注意:window.opener.location.href只是一个链接,如果想实现父窗口的提交就要调用window.opener.action="" 和window.opener.submit();方法,但是不幸的是这段代码在firefox下不能运行,解决的办法为在父窗口中写一个提交的function在子窗口中通过window.opener.functionname()调用。
通常在使用window.opener的时候要去判断父窗口的状态,如果父窗口被关闭或者更新,就会出错,解决办法是加上如下的验证if(window.opener && !window.opener.closed)
例一:
Response.Write("<script language='javascript'>window.opener.location.href = window.opener.location.href;window.close();</script>");
例二:
Response.Write("<script language='javascript'>");
Response.Write(" window.opener.location.reload(); ");
Response.Write(" window.close(); ");
Response.Write("</script>");
例三:
父页是显示标题,弹出页修改标题提交后,父页更新:
<script language=javascript>
function winclose() {
window.opener.location.reload();
window.close();
}
</script>
<input type=button name=close value="关闭" onclick=winclose()>
- window.opener.location.reload() and href()的区别 弹出页修改后刷新父窗体
- window.opener.location.reload() and href()的区别 弹出页修改后刷新父窗体 .
- window.opener.location.reload() and href()的区别 弹出页修改后刷新父窗体
- window.opener.location.reload() and href的区别
- (转)window.opener.location.reload() and href的区别
- window.opener.location.reload() and href的区别
- window.opener.location.reload() and href()的区别
- window.opener.location.reload() 弹出窗口关闭时用来刷新父窗 口
- window.location.href/replace/reload()--页面跳转+替换+刷新 区别
- window.opener.location.reload()的使用
- window.location.href和window.location.reload()方法在ajax提交后返回页面重新加载时候的区别
- window.location.href,window.location.replace(),window.location.reload() 三者的区别
- window.location.href,window.location.replace(),window.location.reload() 三者的区别
- window.location.href,window.location.replace(),window.location.reload() 三者的区别
- window.location.href,window.location.replace(),window.location.reload() 三者的区别
- JavaScript window.opener.location.reload
- window.location.reload()与window.location.href区别
- window.location.Reload()和window.location.href 区别
- 在Linux终端下使用代理访问网络
- java 环境变量配置
- 带分数
- 递归与分治策略
- hdoj_2048 神、上帝以及老天爷
- window.opener.location.reload() and href()的区别 弹出页修改后刷新父窗体 .
- 【虚拟化实战】存储设计之五IOPS
- android 即时通讯
- 基于spring的调用web形式的cxf服务的方法
- checkStyle代码规范
- apache_commons_io中的FileUtils学习
- WIN8开发中使用进度条
- windows7X64环境下wamp开启PHP_Curl组件
- COM技术