Javascript – Iframe – the address where the iframe is located

For security, you can’t directly reach the page outside the iframe from it. On the other hand, we can recover information from the Browsers.

Publicités

To retrieve the parent’s address, i.e. where the iframe is added, just write this:

<script type="text/javascript">
var url (window.location!) - window.parent.location)? document.referrer: document.location;
alert (url);
</script>

This doesn’t work if your iframe is also in an iframe.

Publicités

Leave a Reply