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