Web Developement Question

Hi

My girlfriend is doing web developement for her company and she has run into a snag. She would like to set up her site to detect what version of web browser is looking at it and if the browser is too old it will pop up a message that prompts the viewer to upgrade to a newer version and maybe include a link to the place where they can download the newest version. Is there a simple/easy way to do this?

Most sites I have seen have just had a note somewhere on the page that says something to the effect of ‘Best viewed with IE 5.0 or better’ and includes a link to the site where the user can upgrade their browser. She does not want to settle for this method however.

I thought to ask the most knowledgable group of people I know about this. Can you help us out?

Any help would be appreciated.

Thanks in advance,
John

If your girlfriend knows anything about Java Script this Script should work for her.


<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var name = navigator.appName;
var vers = navigator.appVersion;
vers = vers.substring(0,1); // or 0,4  could return 4.5 instead of just 4

if (name == "Microsoft Internet Explorer")
url="msie";
else
url="netscape";
url += vers + ".html";
document.write('<center>');
document.write('<A HREF="' + url + '">Enter</A>');
document.write('</center>');

// You may make the redirection automatic by using this
// window.location=url;
// instead of the three document.write lines above

// End -->
</script>

That’s a nice, succinct script robgruver gave, and that will cover almost all your bases. Also remember that older browsers may not have JavaScript, so you might want to do something in a <NoScript> tag, which, if your Girlfriend is familiar with JavaScript, she probably knows how to use. However, this will not actually tell you which browser is being used, just that it is old (or has JavaScript disabled for some peculiar reason).

You can also do it as a server side include. This way your browser doesn’t need to support JavaScript. Here’s a simple example perl program:

#!/usr/local/bin/perl


($browser = $ENV{'HTTP_USER_AGENT'});

if($browser =~ m/msie 2/){
	print "&lt;p&gt;&lt;b&gt;Get a new browser&lt;/b&gt;&lt;/p&gt;";
}

if($browser =~ m/Mozilla/2/){
	print "&lt;p&gt;&lt;b&gt;Get a new browser&lt;/b&gt;&lt;/p&gt;";
}
	
if($browser =~ m/aol/){
	print "&lt;p&gt;&lt;b&gt;Get a new ISP&lt;/b&gt;&lt;/p&gt;";
}

# etc...

In the html, use an SSI tag to run the perl program. Something like this:

<!–#exec cgi="/cgi-bin/detect.cgi" -->

I don’t think this will run on an NT server. For that I’m sure there’s an ASP thing that will do something similar.

I feel obligated to point out that she shouldn’t be doing this; it’s only going to piss people off. People know what browser version they have and if it’s an old one, there’s a good reason for it. Nobody is going to visit your girlfriend’s site, see the error message and smack his head, saying, “Well, color me outdated. It says here I need IE 5, and I’m still using Mosaic! Gee, I wonder where I can download a new version… Hot diggity, there’s a link right here!”.

If you are going to try to detect the browser (and don’t forget other ones, like Opera), at least redirect the visitor to a simpler version of the site.

Remember, the appeal of the Web is content, not whizbangitude.

I agree with jmonster. If you want to look professional skip the idea.

Instead, do a TEXT only version of the site & have a link for that.

Designers should definitely pay attention to jmonster’s comment. When I visit a website, I am doing the owner or designer a favour. Not the other way round. There are millions of other websites I could visit, so you have to persuade me why I should look at yours. Telling me I have to meet your requirements before I enter is guaranteed to drive me away.

The best things you could do are:

  1. Design a website that will appear in many browser types and versions. It’s not impossible, or even difficult, and need not be a boring text-only slab.

  2. Offer an alternative version, as handy suggests, for different browsers.

(PS: I’m not having a go at you or your girlfriend, JCorre, I meant ‘you’ in a generic sense!)

Thanks for the help. I just sent her the link to this thread.

She is fully cognizant of the issues that jmonster and mattk brought up. When she gets the thing up and running I’ll post the link if anyone is curious.

Once again thank you and I knew I could trust this board for good advice.

Don’t worry mattk I did not take offense.

John

A hearty second/third/fourth of the “Bad Idea” votes. You’ll just wind up making customers angry. Really.