Lorenzo Thurman said the following on 9/8/2006 2:00 PM:
Is there a shorthand way to assign the same actions to multiple handlers
? I know I can just just do:
onBlur='myFunction()';onClick='myFunction()'
I'm just looking to save some keystrokes. I actually have this issue now
and it involves a couple of functions with long parameter lists.
<element id="someID" onclick="something('longParameterList')">
window.onload=duplicateThem()
function duplicateThem(){
document.getElementById('someID').onblur=document. getElementById('someID').onmouseover
}
How do you blur something without clicking it though?
The only way to do that is by setting focus via script and if you are
doing that, you simply call the same function.
Or you can write a wrapper function:
function dummyFunction(objectCallingMe){
someOtherFunction('All my parameters here',objectCallingMe)
}
objectCallingMe is in case you are passing "this" as a parameter.
onclick="dummyFunction()" onblur="dummyFunction()"
Of all the possibilities, I would combine the two, it allows less room
for typo errors.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/