Check if the URL will redirect the parent page after loading it in iFrame

I am wondering if there is an easy way to test the URL before loading it into an iFrame to see if it will try to redirect the parent page (for example, the iframed page does not want to be iframed - nyt, google, MS).

If he redirects the parent page, I won’t load it in the iFrame, and then allow the user to go to the URL on their own. This seems to be less intrusive and easy than dumping with onbeforeunload or similar methods.

Thanks in advance!

+4
source share
1 answer

Short answer: Not really.

Long answer: knowing whether the URL will be resolved on a page that does not want to be in the iFrame, you need to know before loading it whether the page has a script, due to which it will jump out the iframe and into a new tab / window.
If you have an exhaustive list of those pages that have this functionality, then you just need to check whether the link you are trying to open is in this list, and then decide what to do with it.

+2
source

Source: https://habr.com/ru/post/1383374/


All Articles