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

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

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

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

留言 0

暂无留言。