I am trying to create a navigation page that will go to a selected url in 5 seconds after clicking the "go in 5" button. After the user clicks the button its text should show the passing time, i.e. it should say "Go in 5", "Go in 4", "Go in 3", etc. After the URL has been loadad it should say "Go in 5" again. I am getting a runtime error when I run this. Any idea why? Code below: <html> <head> <title>Navigator</title> <script type="text/javascript"> function loadurl() { var loadedurl = document.navigate.entered_url.value; if (loadedurl.length > 0) {parent.document.frames['content'].location.href=("http://" + loadedurl);} // load entered_url into content frame else {parent.document.frames['content'].location.href="http://www.pitt.edu"; // if no entered_url, load www.pitt.edu into content frame } } function go() { } var time = 5*1000; function countDown() { time = time - 1000; if (time <= 0) parent.document.frames['content'].location.reload(); // load entered_url into content frame else { setTimeout(countDown, 1000); document.getElementById("time-left").innerHTML = (time/1000).toFixed(0); } } </script> </head> <base target="content"> <form name="navigate"> <body style="background: blue;"> <input type="button" value="Back" onclick="history.go(-1);return true;"> <input type="button" value="Forward" onclick="history.go(1);return true;"> <input type="text" name="entered_url" size="100"> <input type="button" value="Go" onclick="loadurl()" /> <input type="button" value="Go in 5" id="time-left" onclick="countDown()" /> </body> </form> </html>
you can't set innerHTML on a button element, it has none. set the value instead: document.getElementById("time-left").setAttribute("value", (time/1000).toFixed(0)); Code (markup): this would not have caused an error though i'm getting parent.document.frames is undefined Line 25 which is fair enough, i dont have your frameset