Hello, i was reading a book that attempts to teach javascript. I have not gotten very far on it but i saw this one example which i have tried various times but have not gotten it to work properly. It is mentioned in the book that you can have an html link that goes into one website while having a javascript that gets the id of the link and uses a function in order to redirect to another website. I imagine the intention is to have users with javascript disabled to be redirected to one while users with javascript to go to another page. The problem is that when i click the link the javascript function isnt enabled, therefore, i am just directed to the page placed on the html link tag.
these are the codes:
<html>
<head>
<sript language=”JavaScript”
type=”text/javascript”
src=”practice2.js”>
</script>
</head>
<body>
<a href=”
</body>
window.onload initAll
function initAll() {
document.getElementById(“redirect”).
onclick = initredirect;
function initredirect() {
window.location = “
return false;
}
In these examples i just used yahoo and google. Please tell me what i am doing wrong i have typed it over and over. Thanks for the help in advance.