Unsafe JavaScript attempt to initiate navigation for frame with URL 'http://www.xxx.xxx/' from frame with URL "https://open.weixin.com/xxxxxxx" The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor is it processing a user gesture
今天在开发微信扫码登陆的时候,在谷歌浏览器调试的时候遇到了这样一个问题,后来查了半天,才发现原来是iframe的问题,
iframe 有个属性sandbox
| allow-same-origin | 允许 iframe 内容被视为与包含文档有相同的来源。 |
| allow-top-navigation | 允许 iframe 内容从包含文档导航(加载)内容。 |
| allow-forms | 允许表单提交。 |
| allow-scripts | 允许脚本执行。 |
本文介绍了解决微信扫码登录过程中遇到的iframe导航错误的方法。通过设置iframe的sandbox属性,允许同源、顶级窗口导航及脚本运行,成功解决了谷歌浏览器调试时出现的导航异常。
1万+





