...

View Full Version : Tables not behaving themselves!



3D_Dog_Man
05-03-2004, 03:10 AM
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

nolachrymose
05-03-2004, 03:45 AM
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:


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! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum