javascript:逃走的按钮
来源:优易学  2010-1-15 12:31:59   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  <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,否则对于许多浏览器都不能正确设置该

  值。

上一页  [1] [2] 

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训