关于window.opener无效问题

问题描述:

在父窗口中window.open()打开一个子窗口,  子窗口通过window.opener.document.getElementById().innerHTML="" 来给父窗口传至时无效

经过测试, 在IE10中可行, 但是在opera和chrome中无效

a.html

<body>
    <span id="fatherWin"></span><br/>
    <a href="javascript:void(0)" οnclick="window.open('b.html','_blank')">getChildWindow</a>
</body>

b.html

<pre name="code" class="html"><body>
    <scritp>
        window.opener.document.getElementById('fatherWin').innerHTML="I'm the Father Window";
    </script>
</body>

 

将b.html进行修改以后,opera和chrome中测试, 发现alert(1)执行, alert(2)不执行, 说明是window行异常

<pre name="code" class="html"><body>
    <scritp>
        alert(1);
        window.opener.document.getElementById('fatherWin').innerHTML="I'm the Father Window";
        alert(2);
    </script>
</body>


 


之后与之进行了长时间的斗争, 最终发现一些端倪

不要用webkit核心浏览器来测试本地资源!!!

上述代码部署到服务器中就可测试通过

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值