setTimeout 一直循环问题

baidu_28166299 2015-06-09 04:21:51
 function f() {
if (document.all) {
IsTrue = true;
document.getElementById("btnSele").click();
}
// 其它浏览器
else {
IsTrue = true;
var e = document.createEvent("MouseEvents");
e.initEvent("click", true, true);
document.getElementById("btnSele").dispatchEvent(e);
}
}
var t1 = window.setTimeout("f()", 1000);


为什么一直在循环执行
...全文
313 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
每刷新一次Page,也只会进一次啊,你这个怎么能算循环呢……
baidu_28166299 2015-06-10
  • 打赏
  • 举报
回复
引用 1 楼 starfd 的回复:
这个你确认一直在执行?
function f() {
        //这里加段print或者console看看
        if (document.all) {
            IsTrue = true;
            document.getElementById("btnSele").click();
        }
        // 其它浏览器
        else {
            IsTrue = true;
            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            document.getElementById("btnSele").dispatchEvent(e);
        }
    }
    var t1 = window.setTimeout("f()", 1000);
因为页面刷新了所以一直在重新载入js 一直在走这个方法
  • 打赏
  • 举报
回复
这个你确认一直在执行?
function f() {
        //这里加段print或者console看看
        if (document.all) {
            IsTrue = true;
            document.getElementById("btnSele").click();
        }
        // 其它浏览器
        else {
            IsTrue = true;
            var e = document.createEvent("MouseEvents");
            e.initEvent("click", true, true);
            document.getElementById("btnSele").dispatchEvent(e);
        }
    }
    var t1 = window.setTimeout("f()", 1000);

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧