9

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>

But it doesn´t work. Firebug says: Permission denied to access property 'href'

I´m on same domain so what´s the problem? I try to do it in Wordpress theme.

4

2 回答 2

9

只有当父子节点从相同的协议(http/https)、相同的主机和相同的端口运行时,您的代码才能工作。这称为同源策略 (SOP)。您可以查看以下参考: http ://en.wikipedia.org/wiki/Same_origin_policy

于 2013-04-04T11:37:23.597 回答
0

您可以document.domain="domainName:port"在 Firefox 中设置。不能设置端口的默认值,如果端口不同,请自行设置!</p>

于 2016-10-11T15:29:05.370 回答