...

View Full Version : Changing a link's destination via DOM....



dep
12-15-2005, 09:09 PM
So I have this:

<A HREF="javascript:dothis();" id="link">

But, via DOM, I want to change the javascript to "javascript:dothat();"

i thought it'd be something like:
document.getElementById("link").nodeValue = 'javascript:dothat();'

but alas, this does not work.

any help?

thanks,
dep

Basscyst
12-15-2005, 09:27 PM
Change your link to this:



<a href="#" id="link" onclick="doThis();return false;">Link</a>


Then the JS:



document.getElementbyId('link').onclick=function(){doThat();return false;};


Basscyst

dep
12-15-2005, 09:58 PM
Change your link to this:



<a href="#" id="link" onclick="doThis();return false;">Link</a>


Then the JS:



document.getElementbyId('link').onclick=function(){doThat();return false;};


Basscyst

Hey, that'll work. Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum