简体   繁体   English

一旦将父页面加载到iFrame中,检查网址是否会重定向父页面

[英]Check if a URL will redirect the parent page once its loaded into an iFrame

I am wondering if there is a simple way to test a URL before I load it into an iFrame to see if it will try to redirect the parent page (eg the iframed page does not want to be iframed - nyt, google, MS). 我想知道是否有一种简单的方法来测试URL,然后再将其加载到iFrame中以查看它是否将尝试重定向父页面(例如,iframed页面不想被iframed-nyt,google,MS)。

If it will redirect the parent page I will not load it into the iFrame and then give the user the option to navigate to the URL on their own. 如果它将重定向父页面,则我不会将其加载到iFrame中,然后为用户提供自行导航到该URL的选项。 This seems like it should be less intrusive and easier than mucking with onbeforeunload or similar methods. 与使用onbeforeunload或类似方法进行处理相比,这似乎应该更具侵入性并且更容易。

Thanks in advance! 提前致谢!

Short Answer: Not really. 简短的回答:不是。

Long Answer: Knowing whether or not a URL is going to resolve to a page that does not want to be in an iFrame requires knowing, before you load it, whether the page has a script which causes it to pop out of the iframe and into a new tab/window. 长答案:知道URL是否将解析为不希望包含在iFrame中的页面需要在加载页面之前知道该页面是否具有导致其从iframe中弹出并进入其中的脚本。一个新的标签/窗口。
If you had a conclusive list of which pages do have such functionality, then it would just be a matter of checking if the link you're trying to open is in that list and then deciding what to do with it. 如果您有哪些页面确实具有此类功能的最终列表,那么只需检查您要打开的链接是否在该列表中, 然后决定如何处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM