关于window.opener无效问题
2015-11-23 16:11
946 查看
问题描述:
在父窗口中window.open()打开一个子窗口, 子窗口通过window.opener.document.getElementById().innerHTML="" 来给父窗口传至时无效
经过测试, 在IE10中可行, 但是在opera和chrome中无效
a.html
<body>
<span id="fatherWin"></span><br/>
<a href="javascript:void(0)" onclick="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核心浏览器来测试本地资源!!!
上述代码部署到服务器中就可测试通过
详情可以参照该文章:http://www.coding123.net/article/20141105/chrome-file-access-can-not-get-iframe-parent-opener-nul.aspx
在父窗口中window.open()打开一个子窗口, 子窗口通过window.opener.document.getElementById().innerHTML="" 来给父窗口传至时无效
经过测试, 在IE10中可行, 但是在opera和chrome中无效
a.html
<body>
<span id="fatherWin"></span><br/>
<a href="javascript:void(0)" onclick="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核心浏览器来测试本地资源!!!
上述代码部署到服务器中就可测试通过
详情可以参照该文章:http://www.coding123.net/article/20141105/chrome-file-access-can-not-get-iframe-parent-opener-nul.aspx
相关文章推荐
- Linux中web服务运行情况的方法
- 网站用户异步登录时出现特殊符号丢失
- 利用第3方开源框架 Volley ,实现图片,网站源码的加载
- Linux Shell 编程语法
- linux shell编程
- proxool+tomcat配置
- linux block IO open的顺序图(二)
- linux截取指定字符shell cut awk
- 《大型网站技术架构》——核心原理与案例分析
- linux设置tab键的宽度为4
- 最简单的视音频播放示例6:OpenGL播放YUV420P(通过Texture,使用Shader)
- 使用C编写shellcode
- linux 显示文件的前n行 head
- make -C $(KDIR) M=$(shellpwd) modules
- Linux字符设备驱动--设备注册
- 【云计算虚拟化】docker在ubuntu14.04下的安装
- centos 配置 lnmp
- SEO网站优化方案
- linux 文件排序 sort
- Tomcat使用java+mysql连接池一定时间后不响应问题