Hi Soren Twilight,
Try something like below instead of your switch case:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Positioning content dynamically</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<style type="text/css">
#myLayer{
position: absolute;
left: 150px;
top: 100px;
}
</style>
<script type="text/javascript">
function moveX(obj, pos){
if(document.getElementById){
var elem = document.getElementById(obj);
elem.style.left = pos + "px";
}
}
function moveY(obj, pos){
if(document.getElementById){
var elem = document.getElementById(obj);
elem.style.top = pos + "px";
}
}
</script>
</head>
<body>
<div id="myLayer">
this is a positionable layer.
</div>
<div>
<a href="#" onclick="moveX('myLayer','100');return false">Move to left:100</a>
|
<a href="#" onclick="moveX('myLayer','200');return false">Move to left:200</a>
|
<a href="#" onclick="moveY('myLayer','250');return false">Move to top:250</a>
|
<a href="#" onclick="moveY('myLayer','70');return false">Move to top:70</a>
</div>
</body>
</html>
Hope this help!
Bookmarks