SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Canberra
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to display a different navigation menu for different browsers?

    I am trying to overcome the problem with IE and the various OSs associated with it.

    I was wondering if anyone knows of a script (such as an IF statements or similar) that would identify the users browser and operating system and subsequently display a specific navigation menu that is functional for that user.

    The information (the menus) would be stored in a CSS file rather than on each page and accessed through the script...

    I don't know at all much about coding javescripts, but know my way around html and xhtml.

    Does anyone have any ideas or possible solutions?

    Cheers
    SmokyLynx

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Location
    Tacoma, WA
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Smoky,

    http://www.quirksmode.org/js/detect.html has a very nice explanation of using JavaScript to check for browser.
    TheNewsFeeds.com - Feed your RSS Needs
    IPThing.com - Make longggggg URLs short!

  3. #3
    SitePoint Addict Wildhoney's Avatar
    Join Date
    Apr 2006
    Location
    Nottingham
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the function I utilise:

    Code:
    function getBrowser()
    {
    	var agt=navigator.userAgent.toLowerCase();
    	if (agt.indexOf("opera") != -1) return 'Opera';
    	if (agt.indexOf("staroffice") != -1) return 'Star Office';
    	if (agt.indexOf("webtv") != -1) return 'WebTV';
    	if (agt.indexOf("beonex") != -1) return 'Beonex';
    	if (agt.indexOf("chimera") != -1) return 'Chimera';
    	if (agt.indexOf("netpositive") != -1) return 'NetPositive';
    	if (agt.indexOf("phoenix") != -1) return 'Phoenix';
    	if (agt.indexOf("firefox") != -1) return 'Firefox';
    	if (agt.indexOf("safari") != -1) return 'Safari';
    	if (agt.indexOf("skipstone") != -1) return 'SkipStone';
    	if (agt.indexOf("msie") != -1) return 'Internet Explorer';
    	if (agt.indexOf("netscape") != -1) return 'Netscape';
    	if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
    	if (agt.indexOf('\/') != -1) {
    	if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
    	return navigator.userAgent.substr(0,agt.indexOf('\/'));}
    	else return 'Netscape';} else if (agt.indexOf(' ') != -1)
    	return navigator.userAgent.substr(0,agt.indexOf(' '));
    	else return navigator.userAgent;
    }
    ...And then you would do like:

    Code:
    if(getBrowser() == 'Opera')
    {
    
    }
    TalkPHP.com - The Friendly PHP Community

    Watch Reaper Online - Watch Chuck Online

  4. #4
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Canberra
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys I'll follow this up and make it work

    Much appreciate your time and imput

    Cheers
    Smoky


Bookmarks

Posting Permissions

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