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 4 of 4
  1. #1
    Senior Coder
    Join Date
    Aug 2002
    Location
    A 4D universe
    Posts
    1,337
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Redirecting in accorance to browser...

    Hey all,

    I am in an icky situation at the moment.

    Basically to the point, I have a menu. In different browsers, it appears in different places, not much that I can do about it, seeing as it is (as far as I am aware) all to do with the way that the browser interprets the code and that.

    Anyway, I need to, because of this I need to put up a certain menu depending upon the browser used, e.g. if it is Mozilla, it would go to moz_menu.js, and Opera would go to op_menu.js, and so on.


    Any help would be appreciated all.

    I am pretty sure that I have the right forum, because I think it is a javascript that will help do this; if not just do your thang mods.






    Ionsurge.
    http://www.mudsplat.com - Web design, print, and marketing solutions.

  • #2
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to parse the userAgent string to differentiate between browsers. For example:

    Code:
    var ua=navigator.userAgent;
    
    // Internet Explorer 5 or greater.  Spoof-proof for Opera.
    var brIE5=(ua.indexOf('MSIE') != -1 && parseInt(ua.split('MSIE ')[1]) >= 5 && ua.indexOf('Opera') == -1) ? true:false;
    
    // Any Gecko Browser, including Netscape 6+, Mozilla, Phoenix, 
    // Camino, Galeon, K-Meleon, AOL 7 for Mac OSX, and CompuServe 7.
    // Spoof-proof for Safari.
    var brGecko=(ua.indexOf('Gecko') != -1 && ua.indexOf('Safari') == -1) ? true:false;
    
    // Netscape 4.x
    var brNS4=(document.layers) ? true:false;
    
    // Opera 6 or greater.
    var brOP6=(ua.indexOf('Opera') != -1 && (parseInt(ua.split('Opera ')[1]) >= 6 || parseInt(ua.split('Opera/')[1]) >= 6)) ? true:false;
    
    // Safari
    var brSafari=(ua.indexOf('Safari') != -1) ? true:false;
    Hope this helps!

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a client-sniffer for this kind of thing - http://www.brothercake.com/scripts/sniffer.php

    Then what I do is have a file called "menu.js", and conditionalise another script include inside that:
    Code:
    var brStr = '';
    if(ie5) { brStr = 'ie5'; }
    else if(op7||ns6) { brStr = 'moz'; }
    //.. and so on ... then
    document.write('<script type="text/javascript" src="menu_'+brStr+'.js"></script>');
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    A 4D universe
    Posts
    1,337
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks all, I am a novice somewhat in this field, so it will take me some time to get this working.

    Cheers for the replies... I'll keep y'all posted.


    http://www.mudsplat.com - Web design, print, and marketing solutions.


  •  

    Posting Permissions

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