[Javascript] Changing the arguments in an onClick event

Paul Novitski paul at novitskisoftware.com
Wed Jun 2 11:30:25 CDT 2004


At 09:21 AM 6/2/2004, Terry Riegel wrote:
><a href="#" onclick="supersize('image1-big.jpg')"><img 
>src="image1-med.jpg" id="mainimage"></a>
>
>I have a script that changes the url, can I also change the onclick url 
>also? Is there a better way to do this?
>
>document["mainimage"].src=url


I think a better (DOMlier) way to do this is:

         var oImg = document.getElementById("mainimage")
         oImg.src = url
         oImg.onclick = function{ DoSomethingElse() }    // with parentheses
or:
         oImg.onclick = DoSomethingElse          // without parentheses

Paul 




More information about the Javascript mailing list