Forum Moderators: open

Message Too Old, No Replies

Browser detection links

Links after browser detection

         

Adam5000

9:53 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



In getting my site to work with both MSIE and Netscape, I've made two home pages. One for MSIE and one for Netscape. The code is different for each one. And when viewers goes to the site, I'd like to send each one to the page that was written for the particular browser that person is using (MSIE or Netscape). Below is the code I've using, and I think the browser detection part works, but I don't know the code for the links to the home pages. Help!

<script language=javascript>
var browserName = navigator.appName;
if (browserName == "Microsoft Internet Explorer")
{send the viewer to MSIE_home_page.htm}
else
if (browserName == "Netscape")
{send the viewer to Netscape_home_page.htm}
</script>

Fotiman

9:56 pm on Mar 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Browser detection is a very, very, very, very BAD idea! Don't attempt to create separate pages like this!

DrDoc

9:57 pm on Mar 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What about Opera and Firefox or Mozilla? What about Safari or other browsers? :)
May I ask why you direct them to separate pages?

Now, for how to do it ... you should really do the direction on the server, using PHP/Perl or something similar.

Adam5000

5:50 am on Mar 25, 2006 (gmt 0)

10+ Year Member



I thought about putting both sets of code on one page. Do you think that will work? It would certainly make updates eaiser on me. My main concern is if I put the code I used for the Netscape browser on the MSIE page, it may interfere with the code for MSIE and throw the page off. And vice versa with the code for the MSIE browser on the Netscape page. Do you think putting the code for both browsers on the same page will work?

And the other browsers are good too and idealy I want my pages to work with all browsers so anyone can view them. And writing the code for Netscape is about as much as I can do for now. But you're right. When I first started this project I asked myself the question "Which browser should I use to test the pages?" And my almost immediate answer was "Every browser I can find." And who knows. I might get lucky and some of the other browsers may work with the code I've already written.

bedlam

7:31 am on Mar 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...who knows. I might get lucky and some of the other browsers may work with the code I've already written...

This is the problem--it show's you're approaching the problems of cross-browser rendering consistency from the wrong angle. Right now, you're trying to respond to browsers' rendering inconsistencies, when you should be trying to prevent them instead.

Take Fotiman's advice, abandon the detection scripts. I might go so far as to say that js browser detection scripts are always a sign that somebody on the team didn't do their homework... Believe it or not, it's easier to write pages that simply work in all (or most) browsers than it is to write pages specifically designed to work in browsers a, b and c as you're doing now.

It's all about the approach. Start by making sure every page you create passes both the w3c's html [validator.w3.org] and css [jigsaw.w3.org] validators. This step alone will fix most major cross-browser rendering inconsistencies.

Then, try to come to grips with css (which will unfortunately mean you have to start learning about the problems with the most sophisticated product ever to come out of the bug-factories in Redmond: Internet Explorer...)

-b

Adam5000

1:23 am on Mar 27, 2006 (gmt 0)

10+ Year Member



That would be great. If there is one set of code that all browsers understand, that would be great. It's double work writing two sets of code for every page and changing double pages for each update. Up to this point, the most recent information I had was written in year 2000 and so I've got six years of catching up to do (Whew).

I've been working hard on what I got and I'm going to go with what I've got for now and take a much needed break.

Ditching the browser detection will be in the next set of changes, but I have to take a much needed break before starting that.