470,619 Members | 1,600 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

browser detection

sorry, I put the original text instead of my changed one in the previous mail sorry


I am new to this forum and a laymen. I have awebsite www.earlyflute.com. I make baroque flutes as you can see there. I renewed my site recently using ap div s and dreamweaver in a template and css to get away from my fifteen yr old frontpage one. However it did not work with IE6 as you probably know. So I made a second version for IE6 and tried to use the browser detection java script shown below. As long as the browser is not IE I get the right version earlyflutenew7, but for IE7 I get version earlyflutenew6 and sometimes it seems from the web statistics that users get the 7 one for IE6. I dont understand it. Please, thisi important for me could somebody solve it????

[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Browser detection</Title>
<Script Language="JavaScript">
// Browserdetectionscript made by Henrik Petersen / NetKontoret
// Script explained at www.echoecho.com/javascript.htm
// Please do not remove this and the two lines above.
// Detect the browsername
{if (browsername.indexOf("Microsoft")!=-1) {browsername="MSIE"}
else {browsername="N/A"}};

//detect the browserversion
if (navigator.appVersion.indexOf("3.")!=-1) {browserversion="3"};
if (navigator.appVersion.indexOf("4.")!=-1) {browserversion="4"};
if (navigator.appVersion.indexOf("5.")!=-1) {browserversion="5"};
if (navigator.appVersion.indexOf("6.")!=-1) {browserversion="6"};

// Send visitor to relevant pages
if (browsername=="MSIE")
if (browserversion<7){window.location="http://www.earlyflute.com/earlyflutenew6/index.html"}
else {window.location="http://www.earlyflute.com/earlyflutenew7/index.html"}
if (browsername=="N/A") {window.location="http://www.earlyflute.com/earlyflutenew7/index.html"};


Oct 19 '07 #1
4 1984
11,448 Expert 8TB
You've asked your question in the Java Articles section where it doesn't belong.
I've moved your question over to the Javascript forum. Good luck.

kind regards,

Oct 19 '07 #2
5,390 Expert Mod 4TB
hi ...

you may have a look at our javascript-articles section, where you will find an answer to your questions, but i strongly recommend not to use browser-detection ... rather use object detection. what that means you can find here ... that is a much better solution and you should consider to use that for you. in case you would have particular problems with it please post back anytime ...

kind regards
Oct 19 '07 #3
Hi you are probably right that I should rather use object detection, but people visiting my website will 99% use either IE(6 or 7) or firefox or safari as I know from many yrs statistics. However, I am quite pleased with myself because I found the problem I think. The code I used from some henrik peterson etc, simply is wrong. In the string where it searches for 5. for instance the 5. may be found in another place then for the version. That makes it go wrong for version detection. I now use another small piece of code that does a parsing such that the number in the right place is used.

Sorrry, you probably will not hear from again.


Oct 19 '07 #4
5,390 Expert Mod 4TB
hi ...

glad to hear you got it working ... in case you have more problems ... then post in the forum again :)

one question regarding to your current (resolved) problem ... do you really need to detect all the versions? as far as i can see you only have 3 cases ... IE 7 or < 7 and the rest of the browsers ... do you need the version-numbers for other code? in case you don't then simply try to detect version 7 and leave the rest as IE or the other browsers ...

kind regards
Oct 19 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Szar | last post: by
8 posts views Thread by R. Smits | last post: by
8 posts views Thread by Jimnbigd | last post: by
4 posts views Thread by trpost | last post: by
15 posts views Thread by CMM | last post: by
7 posts views Thread by Nathan Sokalski | last post: by
10 posts views Thread by Conrad Lender | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.