Here is my code:
function Alert()
{
alert("Please click on OK to continue.")
}
window.onload = function()
{
var anchors = document.getElementsByTagName("a");
for (var i = 0; i < anchors.length; i++) {
anchors[i].onclick = function() {return(false);};
}
};
the link is coded at this:
<a href="main.html" onclick="Alert()"> Link to Main Page</a>
When I put this to test, the link does not work (as expected), but I don't get the alert box that's supposed to say "Please click on OK to continue." when the link is clicked. Can someone give me advice on how to fix this? Ultimately, once the page loads and the the link is clicked, it should show and alert that says "Please click on OK to continue." and nothing should happen. I know how to do this by changing the "href" attribute, but I need to know how to do it without changing that part.