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?
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?
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..