I'll try to be brief.
I know practically nothing about programming, I'm trying to learn by myself for a personal project. I'm trying to do something like a timer which, when it reaches 0, redirects to another page. What I managed to build so far is this:
<!DOCTYPE html>
<html>
<body>
<input type="text" id="txt">
<body onload="startCount()">
<script>
var c = 10;
var t ;
var timer_is_on = 0;
function timedCount() {
document.getElementById("txt").value = c;
c = c - 1;
t = setTimeout(timedCount, 1000);
}
function startCount() {
if (!timer_is_on) {
timer_is_on = 0;
timedCount();
}
}
</script>
</body>
</html>
When I try it on chrome, it doesn't run or it instantly jumps to the other page. If you could tell me what's wrong, or how to fix it, it would be wonderful.
Now, I just discover(?) that I lost the other part that redirects. I used this
<script>
function myFunction() {
location.replace("https://www.w3schools.com")
}
</script>
I don't know if I explained this correctly, but I appreciate the help!!
Thanks!
EDIT: Thanks everyone for the answers!! It's fixed now.