문제

This is the code:

var LOAD = window.setInterval("LOADING()", 50);

function LOADING()   {
  var y = document.getElementById("cse");
  var str = y.innerHTML;
  if (str !== "Loading") {
    setTimeout('INPUTAI()', 100);
    window.clearInterval(LOAD);
    console.log('Google paieška užsikrovė');
  }  
}

Then page loads and then "Loading" dissmises, in my Google Chrome console I see "Google paieška užsikrovė", but it keeps writing to console, and writing... So clearInterval not works.

Problem solved: changed to

var LOAD = window.setInterval(LOADING, 50);

Thanks ;)

도움이 되었습니까?

해결책

setInterval does not need the function's ():

 var LOAD = window.setInterval(LOADING, 50);
  setTimeout(INPUTAI, 100);

Also, as many people ponted out, the problem may be with the #cse element's content not being exactly "Loading".

다른 팁

Try this out?

var LOAD = setInterval(LOADING, 50);

function LOADING()   {
  var y = document.getElementById("cse");
  var str = y.innerHTML;
  if (str !== "Loading") {
    setTimeout(INPUTAI, 100);
    clearInterval(LOAD);
    console.log('Google paieška užsikrove');
  }  
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top