SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Quake 1 Addict CreedFeed's Avatar
    Join Date
    Feb 2002
    Location
    Milwaukee, WI
    Posts
    296
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cross-browser compatibility Question

    Does this menu work in Netscape 4, IE 5.5 or less, and other browsers such as Opera, Mozilla, etc.?

    http://test.creedfeed.com/home.php

    This is just a demo page, not my actual site. I'm trying to implement a dropdown menu.

    Also, about designing multiple templates for different browsers...

    I use PHP to include "template" files on my site. Right now, when you call "home.php" as in the link above, it calls "header.php" which contains all the stuff right before the Welcome message including the menu. How can I do a browser check in the "header.php" file and then display the correct menu for that user? Will server-side code work in an included file? It'd be really easy if I can keep my current templates and do the browser check inside the include file instead of having to go and create a new template file and initiate the browser check elsewhere.

    Thank you
    -- Steve Caponetto
    Quake 1 Resurrection :: CreedFeed

  2. #2
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks good in Internet Explorer 6.0 -- I'm going to assume the same for Internet Explorer 5.5. Opera 6.01 will not dispay the menus due to the following JavaScript error:
    Opera 6.01
    Error:
    name: TypeError
    message: Value on left hand side of '.' is not
    convertible to Object: el.className
    In Netscape 6.2.1/Mozilla the menus work decently; however you have some design problems (which will be alleviated if you remove the:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    from the source. You can do so with the following browser detection script I'm going to give you. It's a combination of one of SitePoint's own browser detection scripts and some tweaks by me for personal use -- but it's wonderful
    PHP Code:
    <?php
    /**
        *    $browser will contain one of the following values:
        *    'iewin' : IE 4+ for Windows
        *    'iemac' : IE 4 for Macintosh
        *    'ie5mac' : IE 5 Macintosh
        *    'nswin' : Netscape 4.x Windows
        *    'nsunix' : Netscape 4.x Unix
        *    'nsmac' : Netscape 4.x Mac
        *    'ns6' : Netscape 6 / Mozilla
    */
    function inAgent($agent)
    {
        global 
    $HTTP_USER_AGENT;
        
    $notAgent=strpos($HTTP_USER_AGENT,$agent)===false;
        return !
    $notAgent;
    }
    if(
    inAgent('MSIE 4')||inAgent('MSIE 5'))
    {
        if(
    inAgent('Mac'))
        {
            
    $browser=inAgent('MSIE 5')?'ie5mac':'ie4mac';
        }
        elseif(
    inAgent('Win'))
        {
            
    $browser="iewin";
        }
    }
    elseif(!
    inAgent('MSIE'))
    {
        if(
    inAgent('Mozilla/5')||inAgent('Mozilla/6'))
        {
            
    $browser="ns6";
        }
        elseif(
    inAgent('Mozilla/4'))
        {
            if(
    inAgent('Mac'))
            {
                
    $browser="nsmac";
            }
            elseif(
    inAgent('Win'))
            {
                
    $browser="nswin";
            }
            else
            {
                
    $browser="nsunix";
            }
        }
    }
    else
    {
        
    $browser="unknown";
    }
    if(empty(
    $browser))
    {
        
    // No browser is declared
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
        
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">\n");
    }
    elseif((
    $browser=="iewin")||($browser=="iemac")||($browser=="ie5mac")||($browser=="nswin")||($browser=="nsunix")||($browser=="nsmac"))
    {
        
    // Internet Explorer or Netscape 4.x
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
        
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">\n");
    }
    elseif(
    $browser=="ns6")
    {
        
    // Netscape 6/Mozilla
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
    }
    else
    {
        
    // Unkown browser
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
        
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">\n");
    }
    ?>
    As you see, I've removed the DOCTYPE definition from my script for the Netscape 6.x/Mozilla browsers -- with it they display spaces in tables (problem you're experiencing with your "test" site).

    Anyway, just modify and salt to taste. And yes, this will work if it is include()d. Hope this helps. Best of luck, and you have a very nice site by the way.

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    Baltimore, MD
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question cross-browser compatibility question

    Will the browser detection script that you provided work for this site?:
    www.streetdiamond.com/rev

    I can get the site to work for IE 6.0 but it doesn't really work right in Netscape 7.2 or Opera 7.52. Also, you can forget about any Mac version of same. Any suggestions?
    Any help is appreciated.
    ~mbmoran







    Quote Originally Posted by Aes
    Looks good in Internet Explorer 6.0 -- I'm going to assume the same for Internet Explorer 5.5. Opera 6.01 will not dispay the menus due to the following JavaScript error:In Netscape 6.2.1/Mozilla the menus work decently; however you have some design problems (which will be alleviated if you remove the:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    from the source. You can do so with the following browser detection script I'm going to give you. It's a combination of one of SitePoint's own browser detection scripts and some tweaks by me for personal use -- but it's wonderful
    PHP Code:
    <?php
    /**
        *    $browser will contain one of the following values:
        *    'iewin' : IE 4+ for Windows
        *    'iemac' : IE 4 for Macintosh
        *    'ie5mac' : IE 5 Macintosh
        *    'nswin' : Netscape 4.x Windows
        *    'nsunix' : Netscape 4.x Unix
        *    'nsmac' : Netscape 4.x Mac
        *    'ns6' : Netscape 6 / Mozilla
    */
    function inAgent($agent)
    {
        global 
    $HTTP_USER_AGENT;
        
    $notAgent=strpos($HTTP_USER_AGENT,$agent)===false;
        return !
    $notAgent;
    }
    if(
    inAgent('MSIE 4')||inAgent('MSIE 5'))
    {
        if(
    inAgent('Mac'))
        {
            
    $browser=inAgent('MSIE 5')?'ie5mac':'ie4mac';
        }
        elseif(
    inAgent('Win'))
        {
            
    $browser="iewin";
        }
    }
    elseif(!
    inAgent('MSIE'))
    {
        if(
    inAgent('Mozilla/5')||inAgent('Mozilla/6'))
        {
            
    $browser="ns6";
        }
        elseif(
    inAgent('Mozilla/4'))
        {
            if(
    inAgent('Mac'))
            {
                
    $browser="nsmac";
            }
            elseif(
    inAgent('Win'))
            {
                
    $browser="nswin";
            }
            else
            {
                
    $browser="nsunix";
            }
        }
    }
    else
    {
        
    $browser="unknown";
    }
    if(empty(
    $browser))
    {
        
    // No browser is declared
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
        
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">\n");
    }
    elseif((
    $browser=="iewin")||($browser=="iemac")||($browser=="ie5mac")||($browser=="nswin")||($browser=="nsunix")||($browser=="nsmac"))
    {
        
    // Internet Explorer or Netscape 4.x
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
        
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">\n");
    }
    elseif(
    $browser=="ns6")
    {
        
    // Netscape 6/Mozilla
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
    }
    else
    {
        
    // Unkown browser
        
    echo("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
        
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">\n");
    }
    ?>
    As you see, I've removed the DOCTYPE definition from my script for the Netscape 6.x/Mozilla browsers -- with it they display spaces in tables (problem you're experiencing with your "test" site).

    Anyway, just modify and salt to taste. And yes, this will work if it is include()d. Hope this helps. Best of luck, and you have a very nice site by the way.

    -Colin


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
  •