首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

window.opener.location.reload() 与 href=href 的差异

2012-11-23 
window.opener.location.reload() 与 hrefhref 的区别window.opener.location.reload()与window.opener.l

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)

热点排行