I am getting the below error when i try to set a hash value to the parent url from iframe which contains another domain url:
Unsafe JavaScript attempt to access frame with URL "URL1" from frame with URL "URL2". Domains, protocols and ports must match.
How can I fix this problem?
Crossframe-Scripting is not possible when the two frames have different domains -> Security.
See this: http://javascript.about.com/od/reference/a/frame3.htm
Now to answer your question: there is no solution or work around, you simply should check your website-design why there must be two frames from different domains that changes the url of the other one.
I was getting the same error message when I tried to chamge the domain for iframe.src.
For me, the answer was to change the iframe.src to a url on the SAME domain, but which was actually an html re-direct page to the desired domain. The other domain then showed up in my iframe without any errors.
Worked like a charm. :)
A solution could be to use a local file which retrieves the remote content
remoteInclude.php
The HTML
From a child document of different origin you are not allowed access to the top window's
location.hash
property, but you are allowed to set thelocation
property itself.This means that given that the top windows location is
http://example.com/page/
, instead of doingyou do need to know the parents location and do
Since the resource is not navigated this will work as expected, only changing the hash part of the url.
If you are using this for cross-domain communication, then I would recommend using easyXDM instead.
I found that using the XFBML version of the Facebook like button instead of the HTML5 version fixed this problem. Add the below code where you want the button to appear:
Then add this to your HTML tag:
The problem is even if you create a proxy or load the content and inject it as if it's local, any scripts that that content defines will be loaded from the other domain and cause cross-domain problems.