简体   繁体   中英

Edit Javascript and affect timer on HTML page in runtime

I am trying to skip timer placed on an HTLM page. Javascript for the TIMER is below:

var t = 60;
var decr = 1;
var handle = null;
var e = null;
function startTimer() {
    if(!e) e = document.getElementById("time");
    e.innerHTML = t;
    handle = setInterval(function() {
        if(t == 0) {
            clearInterval(handle);
            var answer = confirm("Yes/No?")
            if (answer){
                alert("You Clicked Yes!")
                window.location = "https://twitter.com/";
            }
            else{
                alert("You Clicked No!")
            }
        }
        else {
            t -= decr;
            e.innerHTML = t;
        }
    }, decr * 1000);
}
window.onload = startTimer;

What I want is to change the TIMER to 10 seconds as soon as the page gets loaded. I tried to enter the following code in browser location bar:

javascript:document.getElementById('time').innerHTML = "10";

But I'm not getting into it. What'll be the proper way to do it?

Open the console (development tools). If you are using chrome, press F12, then press console and insert the command

document.getElementById('time').innerHTML = "10";

or

document.getElementById('time').value = "10";

and then press enter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM