场景如下:
www.a.com下有一个页面a.html(http://www.a.com/a.html),页面的代码如下:
<html>
<head>
<title>a.html</title>
</head>
<body>
<a href="http://www.b.com/b.html" target="_blank">b.html _blank</a><br>
<a href="#" onclick="window.open ('http://www.b.com/b.html/')">b.html window.open</a>
</body>
</html>
www.b.com下有一个页面a.html(http://www.b.com/b.html),页面的代码如下:
<html>
<head>
<title>b.html</title>
<script>
if(window.opener!=null){
var wuri = window.opener.location.href ;
var q=getQuery(wuri);//获取父窗体地址栏的某一个参数
window.close();
window.opener.location = "http://www.b.com/login.html"
}else{
window.location = "http://www.b.com/login.html"
}
</script>
</head>
<body>
this is the b.html
</body>
</html>
以上的代码,当显示b.html时,在IE7,IE8下都没有问题,而在IE6下有js错误。
各种测试之后,发现跨域是,IE6不允许读取 window.opener.location.href 的值。
为了让以上代码不出现js错误,暂时把b.html更改为如下:
<html>
<head>
<title>b.html</title>
<script>
try{
window.opener.location.href;
}catch(e){
window.opener=null;
}
if(window.opener!=null){
var wuri = window.opener.location.href ;
var q=getQuery(wuri);//获取父窗体地址栏的某一个参数
window.close();
window.opener.location = "http://www.b.com/login.html"
}else{
window.location = "http://www.b.com/login.html"
}
</script>
</head>
<body>
this is the b.html
</body>
</html>
不知道各位仁人志士,有没有不更改原来逻辑的情况下,解决这个问题。
谢谢
分享到:
相关推荐
window.close(),只支持IE6不支持IE7的问题 打开新窗口并且关闭本窗口不弹出要关闭窗口前的提示function openWin(){window.open(‘login.jsp’,”,’fullscreen=yes,menubar=no,resizable=no’);window.opener=null;...
window.opener.location.href = window.opener.location.href 刷新以winodw.showModelDialog()方法打开的窗口 window.parent.dialogArguments.document.execCommand('Refresh'); 或 Response.Write("<script>...
3> IE与FireFox对两个弹出窗口在跨域时的解析也有不同:通过window.dialogArguments操作父窗口时,在IE下不需要指定document.domain而在FireFox下则正好相反需要指定才能生效;采用opener方式操作父窗口时都不需要...
比如点击了a.htm上的一个链接而打开了b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以写为: window.opener.document.getElementById(“name”).value = “输入的数据...
可以看一看啊 博文链接:https://bageer707.iteye.com/blog/74458
对window.open进行封装, 使其更好用, 且更兼容, 很多人说window.open不兼容,其实不是, 因为不能直接执行, 必须通过用户手动触发才行;看代码: 代码如下 var openWindow = function(url, options) { var str = ""; ...
2个页面,加了注释,很清晰。
window.opener,是通过window.open打开子窗体的父窗体的引用。 比如在父窗体parentForm里面,通过window.open(“subForm.html”),那么在subform.html中window.opener就代表parentForm。既然在子窗体中能够拿到父窗体...
JS代码: window.open(); 而当支付成功后,需要关闭支付平台支付成功界面,并在客户端加载客户端支付成功页面,JS代码: window.opener.location.href=url;window.close();
window.opener.location.reload()刷新父窗口window.opener.location.reload() 与 window.opener.location.href=window.opener.location.href 都是弹出窗口关闭时用来刷新父窗口。 但[removed].Reload 如果有数据提交...
使用[removed].reload;...window.opener.location.href=window.opener.location.href; window.opener.location.reload(); 这种写法就不出现那讨厌的对话框啦! 介绍JS实现刷新iframe的方法 <iframe src=”1.ht
(“#父窗口元素ID”,window.parent.document); 对应javascript版本为window.parent.document.getElementByIdx_x(“父窗口元素ID”);取父窗口的元素方法:$(selector, ...$(selector, window.opener.document);$(s
window.opener=null; window.open(”,’_self’); window.close(); firefox IE7,Opera, chrome,safari Close 3 window.open(”,’_self’); window.close(); firefox IE7,Opera, chrome,sa
本文实例分析了javascript关于open.window子页面执行完成后刷新父页面的方法。分享给大家供大家参考。具体分析如下: 主页面: <input id=btnAdd type=button onclick=openWin(); value=添加 /> 在js中有如下...
如果网页 A 可以发送信息到网页 B,反之也然,而不必动用请求/应答模式,该是一件多么惬意的事儿。可以轻松地实现聊天不是吗?