How to get the url from the parent page of an iframe without being in the same domain?

1

I researched postMessage, but I only found examples of iframe resizing.

I would like to know if there is any way to get the URL of the main page where my iframe is inserted using this or some other method.

    
asked by anonymous 05.02.2015 / 14:07

1 answer

1

You can use the following:

var parentURL = window != window.parent ? document.referrer : null;

When your page loads into an iframe, window is different from window.parent . In this case, document.referrer will have the URL of the page that loaded its iframe .

    
05.02.2015 / 15:42