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 14 of 14
  1. #1
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I need a platform-check!

    Hi, I need help again!

    I need to make my site viewable for both PC and Macintosh. For PC the "HV Menu" works very good but it screws up on a Mac. So I've configured "Top Navigational Bar 3 v3.4.1.1b" to work on a Mac.

    Both of the menus use SCRIPT REL/SRC-links to external js-files implemented in the HTML-code of the site (that's 1standard I guess). So what I need is a platform-check in the HTML-code that decides wich menu that will show!

    Down below I attach the scripts from each menu.

    -----------------------------------------
    Top Navigational Bar 3 v3.4.1.1b:

    In HEAD:
    <link rel="stylesheet" href="xtras/styles.css" type="text/css">
    <script language="javascript" src="js/sniffer.js">

    //Top Navigational Bar III v3.4.1.1b (By BrotherCake @ cake@brothercake.net)
    //Permission granted/modified by Dynamicdrive.com to include script in archive
    //For this and 100's more DHTML scripts, visit http://www.dynamicdrive.com/
    //This notice MUST stay intact for legal use

    </script>
    <script language="javascript1.2" src="js/custom.js"></script>
    <script language="javascript1.2" src="js/style.js"></script>

    In BODY:
    <script language="javascript1.2" src="js/menu.js"></script>
    -----------------------------------------

    -----------------------------------------
    HV Menu:

    In BODY:
    <script type="text/javascript">
    function Go(){return}
    </script>
    <script type="text/javascript" src="js/exmplmenu_var.js"></script>
    <script type="text/javascript" src="js/menu_com.js"></script>
    <noscript>Your browser does not support script</noscript>
    -----------------------------------------


    So, all I really need is a way to make the browser choose between wich menu it will show (i.e which code it will show)!

    Please can anybody help me?

    /Xoom

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Surrey, UK
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script>
    if (navigator.userAgent.toLowercase().indexOf("mac")!=-1) {
    //show mac menu here
    } else {
    //show PC menu here
    }

  • #3
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well that's a script which I've been trying to use but I have encountered a problem.

    what I've done is:

    <script>
    if (navigator.userAgent.toLowercase().indexOf("mac")!=-1) {
    <script language="javascript" src="js/sniffer.js">

    //Top Navigational Bar III v3.4.1.1b (By BrotherCake @ cake@brothercake.net)
    //Permission granted/modified by Dynamicdrive.com to include script in archive
    //For this and 100's more DHTML scripts, visit http://www.dynamicdrive.com/
    //This notice MUST stay intact for legal use

    </script>
    <script language="javascript1.2" src="js/custom.js"></script>
    <script language="javascript1.2" src="js/style.js"></script>
    } else {
    <script type="text/javascript">
    function Go(){return}
    </script>
    <script type="text/javascript" src="js/exmplmenu_var.js"></script>
    <script type="text/javascript" src="js/menu_com.js"></script>
    <noscript>Your browser does not support script</noscript>
    }
    </script>

    Cause I can't use script-tags inside a script tag? I've tried using document.write-method too but without success!

    Please, what am I doing wrong?

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Surrey, UK
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When using conditional scripts, document.write out any <script> tags inside the first. BUT, you must break up the <script> and </script> tags:
    document.write("<"+"script src='js/sniffer.js'><"+"/script>");
    for example

  • #5
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh I see! Thanks!!

  • #6
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just wanted to report that your platform-check-script didn't work. It should look like this:

    // If the platform is Macintosh, use the Macintosh style sheet.
    if (navigator.platform.indexOf('Mac') != -1) {
    document.write('<link rel="stylesheet" href="/macstyles.css">');
    // Otherwise, use the Windows style sheet.
    } else{
    document.write('<link rel="stylesheet" href="/winstyles.css">');
    }

    Just if someone else reads this thread and doesn't make it work.

    Peace out! And thanks again for all the help!

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can't help but ask .. why not just use topnavIII for all platforms? make life much easier ..
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #8
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, for starters Top Nav III is much slower. And I haven't been able to configure Top Nav III in the same way as the HV Menu.

    What I thought was perfect in the HV Menu was the TargetLoc-variable that made it possible to lock the menu to a desired tablecell with a DIV-tag (ID=MenuPos) inside. In that way the menu always kept in place, even if you resized the window and such. And it didn't followed out the side of the window.

    Am I wrong?..

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The speed comment is fair - topnav III is slower loading than HV, but it's far more configurable, or at least in it's most recent incarnation it is - http://www.brothercake.com/dropdown/
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #10
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But I can't lock topnavIII into a cell? I must either position it with a static pixelvalue from the left or center it on the page?

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #12
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh ok! let me check that out! sounds great! thnx

  • #13
    New Coder
    Join Date
    Jun 2003
    Location
    Gothenburg, Sweden
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh, this works just fine now! Thank you! But still, I can't get arrow-images on topnavIII right?

  • #14
    Regular Coder
    Join Date
    Sep 2002
    Location
    Surrey, UK
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just to say, I think mine might have worked but there's a typo. Should be:
    toLowerCase() rather than toLowercase()

    But yes, as you've discovered, navigator.platform is also good for the data needed


  •  

    Posting Permissions

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