homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Detecting iframes / javascript enabled browsers
How to tell if a browser doesn't support BOTH

10+ Year Member

Msg#: 523 posted 8:15 pm on Aug 7, 2003 (gmt 0)

I run Google AdSense ads on my site, and Google Uses javascript and iframes to load the ads. However, I have substantial traffic that either has javascript disabled, or use older browsers that either don't support iframes or js (or both).

So, how can I detect if either iframes or javascript doesn't work in a browser, and load a default static banner in those browsers?

In pseudocode:

if (js == true AND iframes = true)
... {load AdSense code}
...{load a default banner}

Keep in mind you can't tamper with the AdSense code itself. Thanks!


Purple Martin

WebmasterWorld Senior Member 10+ Year Member

Msg#: 523 posted 2:57 am on Aug 8, 2003 (gmt 0)

The first thing that springs to mind is that if the script (pseudocode above) is being executed then JavaScript must be enabled.

So you only need to detect iframes in the script, and you also need to put the default banner in a <noscript> tag.

Revised pseudocode:

if (iframes == true) {
...(load AdSense code)
} else {
...(load a default banner)
...(a default banner)


10+ Year Member

Msg#: 523 posted 8:40 pm on Aug 8, 2003 (gmt 0)

Thanks, Purple, that makes sense. So now I just need to figure out how to detect iframes capability, before the AdSense iframe is actually present.

I suppose I could try to insert a small iframe of my own, and if it worked, then I would know the browser supports iframes, but that seems awfully round-about. Anyone know of a better way (that doesn't rely on user-agent strings)?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved