...

node.style.margin = has no effect in Mozilla?

blefler
04-29-2004, 09:49 PM
This code works in IE, the margin and padding of the divs are modified onload, but it has no effect in Mozilla. Why?


<!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">

<script language="javascript">

function resizeThing()
{
var divList = document.getElementsByTagName("div");
for (var i=0; i<divList.length; i++)
{
var node = divList[i];
node.style.margin = 50;
node.style.padding = 20;
}
}

onload = resizeThing;

</script>

<head>
<title>Main Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Language" content="en-us" />

<style type="text/css" media="screen">@import "mtest.css";</style>
</head>
<body>
<div class="thing">
<img src="mtest.jpg"/>
</div>
<div class="thing">
<img src="mtest.jpg"/>
</div>
</body>
</html>

I tried running the function from a button onclick() as well -- still no effect in mozilla. What am I missing here?

Vladdy
04-29-2004, 09:57 PM
Units

blefler
04-29-2004, 10:05 PM
Thanks. Makes much sense. Another case of IE making you think you have the code right.

Here's the code change for the interested.

node.style.margin = "50px";
node.style.padding = "20px";

liorean
04-29-2004, 11:52 PM
Thanks. Makes much sense. Another case of IE making you think you have the code right.It's a devious creature, taking every chance at decieving you that it can. Vicious but alluring to the misinformed and ignorant. Once it's got you in it's grip, it's hard to ever get loose.

Or wait, is that another fairy tale creature?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum