Google chrome client name ..<!--[If browser]>...

Discussion in 'HTML & Website Design' started by Pandy123, Oct 24, 2010.

  1. #1
    Hi guys quick question.. having browser incompatibilities with my template in firefox so Im using a quick fix.

    This works for IE:
    <!--[If IE]>content here<![endif]-->

    However I dont know the browser client to make this work in chrome.

    If you could help out on this it would be great!
    Thanks,
    Andy
     
    Pandy123, Oct 24, 2010 IP
  2. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #2
    Since we only need to hack for IE, no, there is no such thing. Conditional comments are non-standard and only work in IE. If it's not working in Firefox then you coded it wrong.

    Whenever anyone talks of "browser incompatibilities", they almost always mean "it doesn't work in IE" and should say so. If you are using IE to first test your markup, you're doing it backwards.
     
    drhowarddrfine, Oct 24, 2010 IP
  3. subdivisions

    subdivisions Well-Known Member

    Messages:
    1,021
    Likes Received:
    40
    Best Answers:
    1
    Trophy Points:
    145
    #3
    While I agree with this, you could just answer his question.

    Chrome doesn't support 'conditionals', but you can do it with PHP.

    <?php
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    if ( $user_agent  == strpos("$user_agent", "Chrome") ) {
    ?>
    
    <p>This text will ONLY appear if the user is using Chrome.</p>
    
    <?php } ?>
    Code (markup):
    Or:

    <?php
    $user_agent = $_SERVER['HTTP_USER_AGENT'];
    if ( $user_agent  !== strpos("$user_agent", "Chrome") ) {
    ?>
    
    <p>This text will NOT appear if the user is using Chrome.</p>
    
    <?php } ?>
    Code (markup):
     
    subdivisions, Oct 24, 2010 IP
  4. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #4
    Except you are doing two wrong things. 1) Assuming he uses, or can use, PHP and 2) you are condoning browser sniffing, something no one should ever do. You never code to a browser. You always code to standards.

    And, to be clear, it's not that Chrome doesn't "support" conditionals, it's that conditionals are not standard and not supported by anything except IE which needs them to fix all it's irregularities.
     
    drhowarddrfine, Oct 25, 2010 IP
  5. ethikz

    ethikz Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would have to agree with drhowarddrfine...always code to standard because chances are all browsers will be compatible minus IE
     
    ethikz, Oct 25, 2010 IP