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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh Hiding javascript from Mac Browser

    I have a script that is too slow on Mac browsers and would like to hide it from them and provide a different one.
    Can anyone tell me how to alter this script to accomplish that? I got it from PerlScriptsJavaScripts.com and it helps me sniff the browser but I don't know how to

    <script>
    <!--
    v3 = 0; op = 0; ie4 = 0; ie5 = 0; nn4 = 0; nn6 = 0; isMac = 0; aol = 0;

    if(document.images){
    if(navigator.userAgent.indexOf("Opera") != -1){
    op = 1;
    } else {
    if(navigator.userAgent.indexOf("AOL") != -1){
    aol = 1;
    } else {
    ie4 = (document.all && !document.getElementById);
    nn4 = (document.layers);
    ie5 = (document.all && document.getElementById);
    nn6 = (document.addEventListener);
    }
    }
    } else {
    v3 = 1;
    }

    if(navigator.userAgent.indexOf("Mac") != -1){
    isMac = 1;
    }

    // -->
    </script>
    <script>
    <!--

    if(op){ // do this
    alert("You are using Opera");// I'd like this to instead load menu_array.js
    }
    if(ie4){ // do this
    alert("You are using Internet Explorer 4");// I'd like this to instead load menu_array.js
    }
    if(ie5){ // do this
    alert("You are using Internet Explorer 5 or above");// I'd like this to load menu_array.js
    }
    if(nn4){ // do this
    alert("You are using Netscape 4");// I'd like this to instead load menu_array.js
    }
    if(nn6){ // do this
    alert("You are using Netscape 6");// I'd like this to instead load menu_array.js
    }
    if(aol){ // do this
    alert("You are using an AOL browser");// I'd like this to instead load menu_array.js
    }
    if(v3){ // do this
    alert("You are using a pre version 4 browser");// I'd like this to instead load menu_array.js
    }
    if(isMac){ // do this
    alert("You are using a Macintosh browser");// I'd like this to instead load menuMac_array.js
    }

    // -->
    </script>

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, what exactly are you trying to do? Are you using .js files? Is this an all-in-one script? It makes a difference.

  • #3
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much for replying.

    The site I'm working on has several javascript navigation menus.
    The javascript is referenced to separate files.

    I want everyone but mac users to see the javascript as it is.
    I want the Mac users to see a simplified version which I haven't developed yet. I'd rather not create separate Mac HTML.

    Client Site

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I'll give you two answers:

    If you want to sniff for Macs (I assume you're talking about all Mac browsers, and not just Mac IE...), you could use something like this:

    Code:
    if (navigator.useragent.toLowerCase().indexOf('mac') != -1)
    {
    	Do Mac stuff....
    }
    else
    {
    	Do Windows/Linux/Unix/BeOS/All other OS's stuff...
    }
    However, If you want a simpler script that works flawlessly in every browser I've tried, check out Brothercake's List-Based Menus. I've used it for a few of the sites I've worked on recently, and they're brilliant! They also downgrade, are standards-compliant, semantic, and all sorts of other good stuff!

    Either way is up to you, but I'd definitely recommend Brothercake's script.

  • #5
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are all that and a biggie-sized fry.

    I'll go to work reworking the navigation tonight.

    Thanks!


  •  

    Posting Permissions

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