PDA

View Full Version : Set Margins With Javascript?



SlowRoasted
December 1st, 2006, 01:48 PM
Can I set a marginwidth with javascript? I was thinking of something like this:



<script language="javascript">
function getSize() {
if(navigator.appName == 'Netscape'){
var winWidth = window.innerWidth;
var midWidth = winWidth/2 - 476;
var theDiv = document.getElementById("divID");
theDiv.style.marginLeft = 300;

}
}
</script>
</head>
<body bgcolor="#193e5e" style="margin: 0px;" onLoad="getSize();">


of course that is now working:(

ditt0
December 1st, 2006, 06:05 PM
something like this maybe?


if (document.getElementsByTagName) onload = function () {
document.body.style.margin = "30px";
}

SlowRoasted
December 1st, 2006, 06:23 PM
Thanks, I'll try that out on monday:P