Log in

View Full Version : Browser detect script



Eternal_Howl
11-29-2007, 05:53 PM
Due to the hassles I am having with IE 5.5 and lower displaying information correctly as I am now using CSS validated code, I need to be able to detect if a surfer is viewing the page via one of these browsers so it can display a message advising the page won't display correctly and strongly recommend upgrade or switch to a different browser (such as FF or Opera).

All I have found so far in my search is cheesy browser detect scripts that advise what browser you're using. I don't want to annoy my surfers, but I do want to advise them ONLY if their browser doesn't pass that the page will not display correct. I don't want to redirect them anywhere and would prefer if it didn't pop up in a window, but rather sat just below my navigation. Is js the best thing to use or would a php script be better? Thanks.

jscheuer1
11-29-2007, 06:19 PM
If you aren't too worried about folks surfing with an IE browser less than 5 - hardly anyone is using IE 4.x anymore, and even if they are, they know it is a piece of crap, you can just use a conditional:


<!--[if lt IE 6]>
Whatever you'd like to tell the poor souls goes here.
<![endif]-->

No script, PHP, etc. required. IE 5 through and including 5.x will see that, no one else will. It's ordinary HTML to those browsers, a comment to all others.

If you really mean precisely IE 5.5 and less (I don't think there was a version between that and 6), you can use:


<!--[if lte IE 5.5]>
Whatever you'd like to tell the poor souls goes here.
<![endif]-->

molendijk
11-29-2007, 07:45 PM
And if you want to praise the happy souls that don't use IE, put this:

<!--[if !IE]><!-->
You are sooo lucky. You don't use IE! Praising... praising ...
<!--<![endif]-->

Arie Molendijk.

Eternal_Howl
11-30-2007, 05:59 AM
That's exactly what I was after. Not a nagging javascript prompt window. Thank you! I couldn't seem to find anything like this. You're both stars!