Javascript模拟鼠标点击的跨浏览器方案

by shinichi_wtn 2009-10-01 15:46

有时候为了让浏览器自动点击网页中的某个按钮或者容器,我们可以利用Javascript事件来完成这个功能,具体代码如下

window.onload = function () {
    if (window.all) document.getElementById('button').click(); //IE
    else document.getElementById('button').onclick(); //Firefox
}

这段代码即表明了当网页加载成功后,自动点击button按钮

(仅用于Gavatar)

  Country flag

biuquote
  • Comment
  • Preview
Loading

About

shinichi_wtnI'm Shinichi_wtn

Software Engineering Manager at Microsoft

[More...]


Month List