Permission denied to access property 'href'

user887799 picture user887799 · Oct 17, 2011 · Viewed 28.8k times · Source

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.

Answer

Krish_Arjun picture Krish_Arjun · Apr 4, 2013

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