My problem is that I can not get my timeout to work as I want it to work. I have googled for it for a long time and all I get is how I use it for something that does not do anything else. I want my button to first change the text (which works perfectly fine if I erase the link) and then after 2 seconds link to another address...
I am not sure if it is an error on my html or js file so I will show both.
Code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="html.css" />
<title>Sinister Darkness</title>
</head>
<body>
<h1 id="h1">Greetings stranger</h1>
<button onclick="h1()" input type="button" value="Redirect">Leave this page and enter a huge encyclopedia</button>
<script src="html.js"></script>
</body>
</html>
function h1() {
document.getElementById("h1").innerHTML="Have a nice day!";}
window.setTimeout("function h1()",2000);
function h1() {window.location = "http://www.wikipedia.org/"
}
I have tried to change the
window.setTimeout("function h1()",2000);
to
window.setTimeout("h1()",2000);
and
window.setTimeout("h1",2000);
but niether worked.Thanks in advice for your answer.

New Topic/Question
Reply


MultiQuote





|