window.opener.location.reload() 与 href=href 的区别

window.opener.location.reload()与window.opener.location.href=window.opener.location.href都是弹出窗口关闭时用来刷新父窗口。

但window.location.Reload 如果有数据提交的动作,会提示是否提交的(是和否选项)

window.opener.location.href=window.opener.location.href 是定向url提交数据,则不会出现是和否的选择框。


 注意: window.opener.location.href 只是一个链接,如果想实现父窗口的提交就要调用window.opener.action="" 和window.opener.submit();方法,但是不幸的是这段代码在firefox下不能运行,解决的办法为在父窗口中写一个提交的 function在子窗口中通过window.opener.functionname()调用。

 

通常在使用window.opener的时候要去判断父窗口的状态,如果父窗口被关闭或者更新,就会出错,解决办法是加上如下的验证if(window.opener && !window.opener.closed)

posted on 2016-06-23 17:02  xuhuang  阅读(1077)  评论(0编辑  收藏  举报