Detect Browser and Displaying unique code for each browser.

Discussion in 'HTML & Website Design' started by Doug the Great, Jan 2, 2009.

  1. #1
    As you may know, Firefox and IE will generate pages 90% of the time that never look the same even though they are the same page.

    So can someone please point me in the direction of something that cant detect the users browser and display a unique code for every browser this way I can make a page look the same on every browser.

    I've tried Google, but I can't seem to find the right wording so my searches keep turning up nothing.

    Regards
    Doug
     
    Doug the Great, Jan 2, 2009 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    That is absolutely the wrong way to achieve x-browser compatibility.

    Write well formed, well structured, semantic html coupled with css that you understand as it's supposed to work. Once that's done, and you have the rendering you want in modern browsers, it's fairly trivial to apply work-arounds and bug fixes for IE. (In practice, the steps are intermeshed; fixes for IE made as you work.)

    cheers,

    gary
     
    kk5st, Jan 2, 2009 IP
  3. Doug the Great

    Doug the Great Peon

    Messages:
    548
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How come the part of the url I want to display in this iframe is a different location through out all of the browsers?

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <style type="text/css">
    <!--
    #container{
        width:335px;
        height:50px;
        border:1px solid #000; 
        overflow:hidden;
        margin:auto;
    }
    #container iframe {
        width:800px;
        height:750px;
        margin-left:-315px;
        margin-top:-360px;   
        border:0 solid;
     }
    -->
    </style>
    
    </head>
    <body>
    
    
    <div id="container">
    <iframe src="http://" scrolling="no"></iframe>
    </div>
    
    
    </body>
    </html>
    Code (markup):
     
    Doug the Great, Jan 2, 2009 IP
  4. ideamonk

    ideamonk Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here's a way to do it -

    <?php
    $br = strtolower($_SERVER['HTTP_USER_AGENT']); // what browser they use.
    
    if(ereg("msie", $br)) {
        # code for IE browser
    
    } else {
        # code for Firefox / Opera etc
    
    }
    ?>
    
    PHP:
    you can also look on google for list of user_agent strings different browsers use, if you wish to pin point a browser. I sometimes use this trick to alter css for IE6 :p
     
    ideamonk, Jan 2, 2009 IP
  5. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #5
    Two possible reasons, but I'm not on Windows to check IE:
    1) IE is the worst browser on the planet
    2) You're trying to use an inline-frame as a frame.
     
    drhowarddrfine, Jan 2, 2009 IP
  6. lastMinutes

    lastMinutes Peon

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Not sure, but try JavaScript's Object Detection... like if (document.getElementById), or try the Microsoft's IE Conditional Comments for CSS purposes...
     
    lastMinutes, Apr 12, 2009 IP
  7. oarcadescript

    oarcadescript Peon

    Messages:
    34
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Christ no, browser detection is the devil and PHP and JS are the worst.

    use this code to detect ie 6
    <!--[if lt IE 7.]>CONTENT<![endif]-->

    and to detect IE generally:

    <!--[if IE]>CONTENT<![endif]-->
     
    oarcadescript, Apr 12, 2009 IP
  8. lastMinutes

    lastMinutes Peon

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yep, that is what we call Ms conditional commenting. :D
     
    lastMinutes, Apr 21, 2009 IP
  9. brianconor

    brianconor Peon

    Messages:
    192
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Html code for every browser remail same only they change some scripts. So that display in evry browser become change.
     
    brianconor, Apr 22, 2009 IP