# javascript to position absolute div



## andehlu (May 6, 2005)

Does anyone know how to position an absolte div using javascript? I have the following code so far but it doesnt seem to work... i tried taking the top and left attributes out of the inlkine style and that didnt work either.... thanks


```
<html>
<head>

<title>2005 YOPLAIT Minigo Duo Campaign  Online Advertising</title>
	
<script>
function handle_div(){
	document.getElementById('div_layer').top = 345;
	document.getElementById('div_layer').left = 345;
}
</script>

</head>
<body onLoad="handle_div()">

body content

<div id="div_layer" style="position: absolute; left: 400; top: 100; width: 200; height: 200; z-index: 1; visibility: visible;">
	<img src="media/animated.gif">
</div>
	
</body>
</html>
```


----------



## andehlu (May 6, 2005)

the fix:

	document.getElementById('div_layer').style.pixelLeft = 200;


----------

