Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Detecting iframes / javascript enabled browsers

How to tell if a browser doesn't support BOTH

8:15 pm on Aug 7, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 5, 2002
votes: 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!

2:57 am on Aug 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
votes: 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)

8:40 pm on Aug 8, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 5, 2002
votes: 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)?


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members