0

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?

2
  • 1
    Why not just make it 10 seconds in the first place? Commented Jun 21, 2014 at 12:57
  • @JLRishe Actually, its not my page. That's why I want to skip the timer. Commented Jun 21, 2014 at 13:07

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Yes. Thank you. I just got that. Actually what it does if it have any value in var e then don't need to get the value of id='time'. Now I just change value of the var t and it works. Thanks again
Another question. Is there any way that this piece of code executes automatically when a specific page loads i.e. example.com/view.php
As you said, this is another question, and it's completely different from the previous one. Please open a new thread. If my answer helped you can mark it, or you can give your answer and accept it. But you have to close this thread and open a new one.
Ok thanks. I'll do it. I just thought to save a thread. Anyway, silly me.
It's a perfectly logic idea, but, it's a good question and it will be lost if it gets answered in the comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.