Regena said the following on 2/6/2006 8:54 AM:
hi,
I have an image and when a "href" associated with it. on href it
should go to "link1" for example and onClick I have to call a
javascript function.
the way I do is:
<a href = "link1" ><img src="something" name="something"
onClick="javascript function();"></a>
the way its working is onClick its performing the javascript function
but coming back to the original page on fully loading the page. how do
I do it in the right way?
What do you call "the right way"?
<a href="link1" onclick="return someFunction(this.href)">
<img src="..."></a>
And then have someFunction use the href passed to it as a parameter to
set the document.location property:
function someFunction(URLToUse){
//do whatever you want here;
document.location.href = URLToUse;
return false;
}
In the future, do not post pseudo-code, post actual code. function() can
not be the name of a function.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/