window.opener.location.reload() and href()的区别
2010-05-03 18:00
330 查看
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)
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)
相关文章推荐
- 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() and href的区别
- window.opener.location.reload() 与 href=href 的区别
- window.location.href,window.location.replace(),window.location.reload() 三者的区别
- window.location.Reload()和window.location.href 区别
- window.location.Reload()和window.location.href 区别
- window.location.Reload()和window.location.href 区别
- window.location.Reload()和window.location.href 区别
- window.location.Reload()和window.location.href 区别
- Window.location.Reload()和window.location.href 区别
- window.location.href,window.location.replace(),window.location.reload() 三者的区别
- window.location.Reload()和window.location.href 区别
- window.location.Reload()和window.location.href 区别
- window.location.Reload()和window.location.href等联系和区别