iframe弹出式刷新父窗口无法在Chrome或Safari浏览器中工作 [英] iframe popup refresh parent window not working in chrome or safari
本文介绍了iframe弹出式刷新父窗口无法在Chrome或Safari浏览器中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
弹出窗口关闭,父窗口重新加载将用户重定向回主页。
这里是iframe代码:
< iframe src =iframe.php>< / iframe>
这里是iframe中的弹出窗口:
<
if $ {$ b $> $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ -1)
{
left =(screen.width / 2) - (width / 2);
}
if(top == -1)
{
top =(screen.height / 2) - (height / 2);
}
var popupwindow = this.open(url,'','toolbar ='+ toolbar +',menubar ='+ menubar +',location ='+ locationbar +',scrollbars ='+滚动条+',resizable ='+ resize +',status ='+ statusbar +',left ='+ left +',top ='+ top +',width ='+ width +',height ='+ height) ;
}
这里是javascript关闭poup窗口并将用户重定向到主页:
< script>
window.opener.location = /;
window.close();
< / script>';
此过程在Chrome或Safari浏览器中不起作用,但在IE和Firefox中可用。
解决方案使用
window.opener.parent.location.href
而不是 window.opener.location
可在Chrome和Safari中使用 while in an iframe a user submits a popup window form.
the popup window closes and the parent window reloads redirecting user back to homepage.
here is the iframe code:
<iframe src="iframe.php"></iframe>
here is the popup inside the iframe:
function popupwnd(url, toolbar, menubar, locationbar, resize, scrollbars, statusbar, left, top, width, height)
{
if (left == -1)
{
left = (screen.width/2)-(width/2);
}
if (top == -1)
{
top = (screen.height/2)-(height/2);
}
var popupwindow = this.open(url, '', 'toolbar=' + toolbar + ',menubar=' + menubar + ',location=' + locationbar + ',scrollbars=' + scrollbars + ',resizable=' + resize + ',status=' + statusbar + ',left=' + left + ',top=' + top + ',width=' + width + ',height=' + height);
}
<a href="javascript:popupwnd()" target="_parent" title="Login into the Site">Login To Buy</a>
here is the javascript to close the poup window and redirect user to homepage:
<script>
window.opener.location = /;
window.close();
</script>';
this process doesn't work in chrome or safari but does in IE and firefox.
解决方案
Using window.opener.parent.location.href
instead of window.opener.location
works in Chrome and Safari
这篇关于iframe弹出式刷新父窗口无法在Chrome或Safari浏览器中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文