This script dosn't work when I attempt to run it

时间:2019-01-09 22:00:29

标签: javascript

When I run this script

function doGet() {
  
}
var seconds = 3; // seconds for HTML
var foo; // variable for clearInterval() function

function redirect() {
    document.location.href = 'krunker.io';
}

function updateSecs() {
    document.getElementById("seconds").innerHTML = seconds;
    seconds--;
    if (seconds == -1) {
        clearInterval(foo);
        redirect();
    }
}

function countdownTimer() {
    foo = setInterval(function doGet(){updateSecs()}, 1000);
}

countdownTimer();

onbeforeunload = function() {return "Stop";}; //Alert  

<p>You should be automatically redirected in <span id="seconds">3</span> seconds.
</p>

Absolutely Nothing happens and I don't understand why. It's supposed to stop a third-party extension (securely) from blocking this website.

1 个答案:

答案 0 :(得分:1)

This looks like the problem:

foo = (function doGet(){updateSecs()}, 1000);

Should it not be

foo = setInterval(function doGet(){updateSecs()}, 1000);