Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you programmatically check if an iframe would be blocked by a site?

I'm generating a bunch of iframes dynamically that load random websites, and I was wondering if there would be a way to programmatically check if iframing for a website were blocked so I can fall back to a thumbnail of the site instead. Is there a way to do this, and if so, how? (JQuery is preferred.)

like image 510
Justin Meltzer Avatar asked Jul 12 '11 04:07

Justin Meltzer


People also ask

How do I know if my iframe is blocked?

If the remote url is not https, or forwards to a non-https url, it will be blocked (by the browser) from displaying in the iframe. If the remote site is indeed https, but contains at least one resource served by http (instead of https), the browser will block the iframe due to mixed content.

How can I tell if a site is using iframe?

In short, to check if a page is in an iframe, you need to compare the object's location with the window object's parent location. If they are equal, then the page is not in an iframe; otherwise, a page is in an iframe.

Does iframe work if Javascript is disabled?

If a user has javascript disabled, iframes will work. An iframe tag has attributes “height” and “width,” which allows the designer great latitude with dimensions and format like 300×250 , 728×90 depending on the Ad size. Iframe tag can appear anywhere on the page and several iframes can be added if wished to.


1 Answers

A very quick and dirty method to bypass some iframing blocks would be to append the url with a free defferer, like http://anonym.to/?site.com, though I don't really recommend this in legitamite practice.

like image 179
Crusty Smith Avatar answered Sep 30 '22 18:09

Crusty Smith