Permission denied to access property 'href'

浪子不回头ぞ 提交于 2019-12-01 00:33:38

问题


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.


回答1:


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




回答2:


You can set document.domain="domainName:port" in Firefox. It can't set a default value of port, you should set by yourself, if the port is different!



来源:https://stackoverflow.com/questions/7798990/permission-denied-to-access-property-href

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!