I am writing a simple lightbox plugin for my application, and I need to embed an iframe that is associated with an arbitrary page. The problem is that many websites (like facebook , nytimes, and even stackoverflow) will check to see if they are embedded inside the frame, and if so, they refresh the page as the parent page. This is a known issue, and I do not think that something can be done about this. However, I would like to know in advance if the site supports embedding or not. If this is not the case, I would like to open the page in a new tab / window instead of using an iframe.
Is there a trick that allows me to test this in javascript?
Perhaps there is a server side script that can check links to see if they allow iframes to be embedded?
I am developing a browser extension, so there is the opportunity to do something very creative. My extension is loaded onto every page, so I think there is a way to pass a parameter to the iframe url that the extension can select if it destroys the iframe. Then I can add the domain to the list of sites that do not support iframe embed. This may work because extensions are not loading inside the iframe. I will work on it, but in the meantime ....
Clarification:
I agree that there is no way to "enumerate" the "frame", i.e. I know that I cannot display a page in an iframe that does not want to be in one. But I want my application to fail, which means opening the link in a new window if iframe embed is not supported. Ideally, I would like to check iframe embed support at runtime (javascript), but I see a potential server solution using a proxy server, as suggested in the comments above. I hope I can create a database of sites that do not allow iframes to be embedded.
javascript jquery google-chrome-extension iframe embed
Matt de leon
source share