browser detection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sjpolak
    New Member
    • Oct 2007
    • 2

    browser detection

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

    hello,

    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.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Browse r detection</Title>
    <Script Language="JavaS cript">
    // Browserdetectio nscript made by Henrik Petersen / NetKontoret
    // Script explained at www.echoecho.co m/javascript.htm
    // Please do not remove this and the two lines above.
    // Detect the browsername
    browsername=nav igator.appName;
    {if (browsername.in dexOf("Microsof t")!=-1) {browsername="M SIE"}
    else {browsername="N/A"}};

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


    // Send visitor to relevant pages
    if (browsername==" MSIE")
    {
    if (browserversion <7){window.loca tion="http://www.earlyflute. com/earlyflutenew6/index.html"}
    else {window.locatio n="http://www.earlyflute. com/earlyflutenew7/index.html"}
    }
    if (browsername==" N/A") {window.locatio n="http://www.earlyflute. com/earlyflutenew7/index.html"};
    </script>
    </head>
    </body>
    </html>
    [/HTML]


    Regards,

    Simon
    Last edited by gits; Oct 19 '07, 04:06 PM. Reason: added code tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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,

    Jos

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #3
      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

      Comment

      • sjpolak
        New Member
        • Oct 2007
        • 2

        #4
        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.

        Regards,

        simon

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5388

          #5
          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

          Comment

          Working...