1

I have an iframe inside a main page. The iframe is from the same exact domain as the main page.

main page url - https://example.edu:4450/... iframe url - https://example.edu:4450/...

But I'm still getting the cross origin frame error while clicking on some buttons that are executing some javascript code inside the iframe page. Why is this happening even though both urls are in the same domain? Is there a way to find out the exact cross-domain url that is causing this error? The alert message doesn't show the cross-domain url that is causing this error.

2
  • You should post the code that produces the cross origin error in the question.
    – Oriol
    Commented Jan 26, 2015 at 17:50
  • I've posted the solution. Commented Jan 26, 2015 at 20:36

1 Answer 1

3

The JavaScript console showed the reason for the error.

Uncaught SecurityError: Blocked a frame with origin "https://dev.nss.xxx.edu:4450" from accessing a frame with origin "https://dev.nss.xxx.edu:4450". The frame requesting access set "document.domain" to "nss.xxx.edu", but the frame being accessed did not. Both must set "document.domain" to the same value to allow access.

The main page's document.domain was set to dev.nss.xxx.edu and the iframe page's document.domain was set to nss.xxx.edu

I added the following JavaScript code to the main page to force the domain to be "nss.xxx.edu" and that fixed the error.

document.domain = "nss.xxx.edu";
1
  • I am having the same problem Both page from same domain and both page with the same document.domain
    – ricardo
    Commented Feb 5, 2015 at 15:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.