I am an intermediate HTML and I am starting to learn JavaScript within it.
<html> <head> <title>Uh oh! No page.</title> <h1 class="index">The page you requested for is not available! Click <a href="index.html" class="index">here</a> to go back</h1> <style> .index { text-decoration: none; font-family: Arial; } </style> </head> <body onload="myfunc()"> <script> function myfunc() { var x; if (confirm("Im confuzzled! Where did the page go?\n\nSelect OK to be redirected and Cancel to do it manually ") == true) { window.location = "index.html"; } else { alert("You will now manually have to redirect to the lemoon homepage"); } document.getElementById("demo").innerHTML = x; } </script> </body> <footer onload="pageLocate()"> <script> function pageLocate() { document.getElementById("demo").innerHTML = "Page location is: " + window.location.href; } </script> </footer> </html>
getElementByIdto look for an element named 'demo" however, you don't have anything in your HTML by that tag id name. Might be helpful to look in web inspector's console to get a reading of Javascript's errors.<h1>probably shouldn't be in the<head>.bodytag. Correct all your HTML before worrying about JavaScript.