<input type="button" onmouseover="move(this);" onclick="alert('骗你的=_=');" value="确定" />
</div>
</body>
<script type="text/javascript" >
var height = document.documentElement.clientHeight - 100; //按钮可能上下移动的距离
var width = document.documentElement.clientWidth - 40; //按钮可能左右移动的距离
function move(obj) {
obj.style.position = "absolute";
obj.style.top = Math.random() * height + "px";
obj.style.left = Math.random() * width + "px";
}
function cancel() {
alert("你已放弃领奖,谢谢!");
window.close();
}
</script>
</html>
四、 注意
(1) style下的属性在被赋值之前为空。
(2) 记得要在style.top/left等之后加上px,否则对于许多浏览器都不能正确设置该
值。
责任编辑:cyth