Detect if remote website is frameable

那年仲夏 提交于 2019-12-12 04:36:29

问题


I want to detect if remote website allows to stand under iframe or not. For example if website does not want to show content under iframe (amazon.com item details page) or if they have frame busting code (walmart.com) I do not want to bother with these websites. I just want to open new window, for others (like wikipedia.com) I want to show content under iframe.

My question is that is there any way to detect if website will accept being under iframe or not?


回答1:


I think there's no such way. You cannot inspect a content of iframe loaded from another domain - and even if you could, it still will be dependent of what exactly the owner of the site decided to put in there. What if someone will design their 'iframed' content exactly the same way as original - but with all page's text encoded in ROT13, for example?




回答2:


The following is one of the Javascript codes used to prevent pages to be displayed in iframe.

if (top.location.href != self.location.href)
  top.location.href = self.location.href;

If it is an include file, it will not be easy to detect it..



来源:https://stackoverflow.com/questions/11129228/detect-if-remote-website-is-frameable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!