SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Conditional comment for Firefox check

    Is there conditional comment to detect Firefox? Like we do for IE with <!--[if IE]>...<![endif]-->?

    Or, is there any other client side check?

  2. #2
    SitePoint Addict fattyjules's Avatar
    Join Date
    Dec 2005
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firefox doesn't have an equivalent to IE's non-standard use of conditional comments (as far as I know).

    There might be some javascript browser sniffing you can do?

    On the server side, you can check your user agent with something like this;

    Code:
    $isFirefox = preg_match('/firefox/i',$_SERVER['HTTP_USER_AGENT']) ? TRUE : FALSE;
    
    if($isFirefox)
    	echo "<p>Yep, using Firefox</p>";
    else
    	echo "<p>Nope, some other browser</p>";
    It's not a guarantee of course; user agent strings are easy to forge.

    You should have a really good reason for discriminating by browser.
    Last edited by fattyjules; Jun 29, 2008 at 19:01.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fattyjules View Post
    IE's non-standard conditional comments
    Ummm it is just a comment there fore it is standard. What IE does when it encounters it may be non-standard but the comment itself is standard.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Addict fattyjules's Avatar
    Join Date
    Dec 2005
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quite right logic_earth. Post edited accordingly.


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
  •