有关div的位置,隐藏显示和移动
<html>
<head>
<script>
functioninit()
{block=blockdiv.style
block.xpos=parseInt(block.left)
block.ypos=parseInt(block.top)
}
functionshowObject(obj)
{obj.visibility="visible"
}
functionhideObject(obj)
{obj.visibility="hidden"
}
function moveto(obj,x,y)
{obj.xpos=x
obj.left=obj.xpos
obj.ypos=y
obj.top=obj.ypos
}
functionmoveby(obj,x,y)
{obj.xpos+=x
obj.left=obj.xpos
obj.ypos+=y
obj.top=obj.ypos
}
</script>
</head>
<bodyonload="init()">
checkvalues:
<br><ahref="javascript:alert('X:'+block.xpos)">横向位置</a>
<br><ahref="javascript:alert('Y:'+block.ypos)">竖向位置</a>
<br><ahref="javascript:showObject(block)">显示</a>
<br><ahref="javascript:hideObject(block)">隐藏</a>
<br>移动moveto:
<br><ahref="javascript:moveto(block,100,200)">(100,200)</a>
<br><ahref="javascript:moveto(block,200,260)">(200,260)</a>
<br><ahref="javascript:moveto(block,300,340)">(300,340)</a>
<br>相对移动moveby:
<br><ahref="javascript:moveby(block,10,0)">(10,0)</a>
<br><ahref="javascript:moveby(block,-10,0)">(-10,0)</a>
<br><ahref="javascript:moveby(block,0,10)">(0,10)</a>
<br><ahref="javascript:moveby(block,0,-10)">(0,-10)</a>
<divid="blockdiv"style="position:absolute;left:100;top:200;width:30;visibility:visible;">
sktjyerlwo;ekrw;
<IMG SRC="1.jpg"border=0>
</div>
</body>
</html>