本文介绍了访问属性'href'的权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试从iframe重新加载父网页。这是我的代码:
I try to reload parent web page from iframe. Here is my code:
<script>
$(document).ready(function() {
window.parent.location.href = window.parent.location.href;
});
</script>
但它不起作用。 Firebug说:拒绝访问属性'href'的权限
But it doesn´t work. Firebug says: Permission denied to access property 'href'
我在同一个域上,所以问题出在哪里?我尝试在Wordpress主题中执行此操作。
I´m on same domain so what´s the problem? I try to do it in Wordpress theme.
推荐答案
只有当父和子从同一个人运行时,您的代码才会起作用协议(http / https),相同的主机和相同的端口。这称为同源策略(SOP)。
您可以查看以下参考:
Your code will be working only when the parent and child are running from the same protocol(http/https), same host and same port. This is known as Same Origin Policy (SOP).You can check the below reference:http://en.wikipedia.org/wiki/Same_origin_policy
这篇关于访问属性'href'的权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!