chrome本地测试访问iframe,parent,opener null解决办法

  使用谷歌chrome浏览器时,如果双击运行或者拖拽html文件进入chrome中以file协议查看js效果,由于chrome的同源策略,父页无法访问iframe中的内容,iframe也无法通过parent对象获取父页的引用。同样对于window.open打开的本地网页,也无法通过opener或者存储打开页面的句柄来访问被打开的页面,在chrome控制台会出现下面类似的错误信息

Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.

  解决办法就是给chrome添加启动参数:配置chrome --allow-file-access-from-files

加支付宝好友偷能量挖...


原创文章,转载请注明出处:chrome本地测试访问iframe,parent,opener null解决办法

评论(0)Web开发网
阅读(3264)喜欢(0)HTML/CSS兼容/XML