Thursday, June 3, 2010

Many websites do have iframes without even knowing

So you are one of those who think iframes are the worst thing ever and should be banned from all websites?

Do you display any advertisements on your website? Yes? Well, then I have news for you. Changes are big that you use iframes on your own website without knowing.

How I found out about this? By accident. I could not get adsense to work on a page with iframes today (a point for the iframe haters here). The ads would just look weird and misplaced.

After a lot of coffee and even more tests, I narrowed the problem down to the "iframe" styling in my CSS file. A quick look at the html source after being modified by the provided javascript functions showed it: The advertisement is always placed in an iframe! Thats why my CSS code for "iframe" did affect the ads.

Conclusion 1: Never style the "iframe" tag without using classes or id's!Conclusion 2: Many websites do have iframes without even knowing