【发布时间】:2019-01-28 11:10:31
【问题描述】:
我用这个代码
<script>
<!-- Hide Script
if (top.location != self.location) {
top.location = self.location
}
//End Hide Script -->
</script>
但最近我在 chrome 控制台中遇到此类错误,并且代码停止工作
(index):15 不安全的 JavaScript 尝试从 URL 为“http://site.test”的框架中为来源为“http://preview.themeforest.net”的框架启动导航。尝试导航的框架以它的顶级窗口为目标,但它既不与它的目标同源,也没有收到用户手势。见https://www.chromestatus.com/features/5851021045661696。
(index):21 Uncaught DOMException: Failed to execute 'replace' on 'Location': 当前窗口无权将目标框架导航到'http://site.test''。
在 Firefox 和 Opera 中,此代码有效。在 Chrome 中它不起作用。
如何修复这些错误?
【问题讨论】:
标签: javascript jquery html