Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question browser and OS detection

    I want to add a link to a map from a web page, my preferred map site is google map but have found that if the user is running IE on win98 their computer hangs. So I need a way of detecting if this instance occurs so that I can point them at multimap instead. I have tried writing the following script but can’t get it to work...

    <script type="text/javascript" language="JavaScript">
    <!--
    if ((navigator.appName>="Internet Explorer")&&(userAgent.indexOf("windows 98"))
    document.write("<a href='http://www.multimap.com/ '>see map<\/a>")
    else
    document.write("<a href='http://maps.google.co.uk/ '>see map<\/a>")
    -->
    </script>

    Can anyone tell me where I am going wrong?

  • #2
    JUD
    JUD is offline
    New Coder
    Join Date
    Jul 2005
    Location
    I'm right here
    Posts
    92
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Noticed a couple of errors in your code:

    Replace

    Code:
    if ((navigator.appName>="Internet Explorer")&&(userAgent.indexOf("windows 98"))
    with

    Code:
    if((navigator.appName.indexOf("Internet Explorer") != -1) && (navigator.userAgent.indexOf("windows 98") != -1))
    That should do it

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks JUD.

    I have been playing around with the code further, and with the help of the “Ranting Hippy” have come up with the following...

    Code:
    <script type="text/javascript" language="JavaScript">
    <--
    if ( (navigator.appVersion.indexOf("MSIE") > 0) && 
         (navigator.userAgent.indexOf("Windows 98") > 0) ) {
    	 document.write("<a href='http://www.multimap.com/’> see map <\/a>");
    } else {
    	 document.write("<a href='http://maps.google.co.uk/ '>see map<\/a>");
    } 
     -->
    </script>
    Which is a variation on JUD's suggestion (but was done before I saw JUD's suggestion) I have tested this code and it works (so far). Feel free to use it if you have a similar problem.

    Kim
    Last edited by dimkim; 08-11-2005 at 11:07 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •