1
I searched postMessage, but only found examples of iframe resizing.
I wonder if you have any way to get the URL of the main page where my iframe is inserted using this method or some other.
1
I searched postMessage, but only found examples of iframe resizing.
I wonder if you have any way to get the URL of the main page where my iframe is inserted using this method or some other.
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 that case, document.referrer
will have the URL of the page that uploaded your iframe
.
Browser other questions tagged javascript url iframe cross-domain
You are not signed in. Login or sign up in order to post.