Change line 14 from this:
clickLink.onClick = promptWhatsName();
to this: clickLink.onclick = promptWhatsName;
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
Your problem is that you keep using document.write AFTER the page has loaded. You should only use it WHILE the page is still loading. Try creating a div with an id and whatever you intend to put via document.write, instead insert it into the div. Also, on the <a> tag, just use href="#" instead of href="javascript:" - ex:
<html>
<head>
<title>Hello everyone</title>
</head>
<body>
<script type="text/javascript">
window.onload = initAll;
function initAll(){
actRedirect();
}
function actRedirect(){
var actLink = document.getElementById("activeRedirect");
actLink.onclick = redirectNow;
}
function redirectNow(){
window.setTimeout(function(){window.location.href='http://google.com';}, 5000);
document.getElementById('target').innerHTML="Please wait, you will be redirect to google soon!";
}
</script>
<div id="target"></div>
<a href="#" id="activeRedirect"> Redirect to Google now.</a>
</body>
</html>
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244
Glad to help.
Regards,
Hielo
PS: Don't forget to mark the thread as solved.
hielo
Veteran Poster
1,124 posts since Dec 2007
Reputation Points: 116
Solved Threads: 244