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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Location
    Chuluota, FL
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    This code works in IE, the margin and padding of the divs are modified onload, but it has no effect in Mozilla. Why?

    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">
    
    <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?
    Bill Lefler
    Intelligent Design Group

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Units
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    New to the CF scene
    Join Date
    Apr 2004
    Location
    Chuluota, FL
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. Makes much sense. Another case of IE making you think you have the code right.

    Here's the code change for the interested.

    Code:
    	node.style.margin = "50px";
    	node.style.padding = "20px";
    Bill Lefler
    Intelligent Design Group

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by blefler
    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?
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

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