Results 1 to 3 of 3

Thread: Why Won't This Appear?

  1. #1
    Join Date
    Aug 2010
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Cool Why Won't This Appear?

    Okay! so what i'm trying to do is make this table appear only in firefox here's my code
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Appear In Firefox</title>
    <script type="text/javascript">
    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
    {
      document.getElementById('Table').style.display='block';
    }
    </script>
    </head>
    <body>
    <table width="200" border="1" id="Table" style="display:none;">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>
    Why isn't it working?
    Any Help is appreciated

  2. #2
    Join Date
    Oct 2009
    Posts
    845
    Thanks
    14
    Thanked 189 Times in 188 Posts

    Default

    you could try something like this instead
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Appear In Firefox</title>
    <style type="text/css">
    #Table { display:none;}
    </style>
    </head>
    <body>
    <table width="200" border="1" id="Table">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    <script type="text/javascript">
    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
    {
      document.getElementById('Table').style.display='block';
    }
    </script>
    </body>
    </html>

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That will 'work', but get you a messed up table because the native display of a table in Firefox is not 'block'. I think it's 'table', but that could change. This is relatively foolproof:

    Code:
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Appear In Firefox</title>
    <style type="text/css">
    #Table {
    	width: 200px;
    	border: 1px outset #000;
    }
    #Table td {
    	padding: 1px;
    	margin: 1px;
    	border: 1px inset #000;
    }
    </style>
    </head>
    <body>
    <table id="Table" style="display: none;">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
    <script type="text/javascript">
    if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
    	document.getElementById('Table').style.display = '';
    }
    </script>
    </body>
    </html>
    Notes: Attributes of the table moved to style as per HTML 5 standards. A browser 'spoofing' itself to be Firefox will see the table. With no javascript, no one will see the table. Except that with all css disabled, anyone can see it.
    Last edited by jscheuer1; 09-01-2010 at 06:45 PM. Reason: slightly better method
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •