Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2004
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Tables not behaving themselves!

    Hi All,

    I have written a script which displays some MIME type information. Part of the information is displayed in a table... however the table renders in the most bizarre fashion, with various rows spaced all over the place. I have included the code below (this only works in Netscape or Mozilla ---> not IE). Could somebody please explain why the tables are not behaving ideally (symetrically)? Also does anybody know why this code won't work in IE?

    <html>
    <head>
    <title>Checking for present MIME types using JavaScript</title>
    <script type="text/javascript">
    <!--
    function showProperties()
    {
    var property;
    for(property in navigator)
    {
    document.writeln(navigator[property] + '<br>');
    }
    }
    function showMIMETypes()
    {
    for(i=0; i<navigator.mimeTypes.length; i++)
    {
    document.write('<table width="100%" border="1">');
    document.write('<tr><td>Type: </td><td>' + navigator.mimeTypes[i].type + '</td></tr>');
    document.write('<tr><td>Description: </td><td>' + navigator.mimeTypes[i].description + '</td></tr>');
    document.write('<tr><td>Plugin: </td><td>' + navigator.mimeTypes[i].enabledPlugin + '</td></tr>');
    document.write('</table>');
    document.write('<br>');
    }
    }
    function showPlugIns()
    {
    for(i=0; i<navigator.plugins.length; i++)
    {
    document.writeln(navigator.plugins[i].name + '<br');
    document.writeln(navigator.plugins[i].description + '<br');
    document.writeln(navigator.plugins[i].filename + '<br');
    document.writeln(navigator.plugins[i].length + '<br');
    document.writeln('<br>');
    }
    }
    //-->
    </script>
    </head>
    <body>
    <h1>This Browsers Navigator Object Properties Are</h1><br>
    <script>showProperties();</script>
    <h1>The Valid MIME Types Accepted By This Browser Are</h1><br>
    <script>showMIMETypes();</script>
    <h1>The Valid Plugins Associated With This Browser Are</h1><br>
    <script>showPlugIns();</script>
    </body>
    </html>

    Thanks

    Regards

    David

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As per the table rendering, I'm not quite sure, although I would recommend that rather than use a table for each MIME type and plug-in, you could store them all in one table. Here's an example:

    Code:
    function showMIMETypes() {
    	var
    		MIMETypes=navigator.mimeTypes,
    		x=MIMETypes.length;
    
    	document.writeln('<table>');
    	document.writeln('<th>Type</th>\n<th>Description</th>\n<th>Plug-in</th>');
    	while(x-->0) {
    		document.writeln('<tr>');
    		document.writeln('<td>' + MIMETypes[x].type + '</td>');
    		document.writeln('<td>' + MIMETypes[x].description + '</td>');
    		document.writeln('<td>' + MIMETypes[x].enabledPlugin + '</td>');
    		document.writeln('</tr>');
    	}
    	document.write('</table>');
    }
    I tested, and it seems IE has added both the navigator.mimeTypes and navigator.plugins collections, but they are not actually implemented. Both have a length property of "0," and that's why the last two functions aren't "working" in IE.

    Hope that helps!

    Happy coding! :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •