Thursday, July 24, 2014

How to solve cross domain parent URL access

So you are here because you were trying to access parent page's url with the child iframe and ran into this error:

"SecurityError: Blocked a frame with origin https://c.ap1.visual.force.com from accessing a frame with origin https://ap1.salesforce.com. Protocols, domains, and ports must match."

In simple words what this means that the site is not allowing you to gain access to the parent frame because it can be used in many hack attacks and is trying to safe guard the application. But if you still need this there is an alternative approach insted of doing this
window.parent.location.href()
You can do this:
var hurl = document.referrer;
So now you can access the cross domain parent url.
Hope this helps some one.

No comments:

Post a Comment