Andrew Urquhart wrote: <%am1c.107$m56. 38@newsfe1-win>
Marek Mand wrote:
<snip> <div ... onClick="someFu nction()">
<script>
function someFunction(){
this.onclick = undefined;
}
</script>
IIRC some javascript engines don't understand the undefined
keyword. Perhaps the following would be better:
A possible trick for guaranteeing the safe use of undefined is to create
a property of the global object called undefined without assigning a
defined value to it:-
this.undefined = this.undefined; // executed inline in
// the global context.
Otherwise, yes the use of - undefined - as a keyword causes IE 4 to
produce that unhelpful "undefined is undefined" error message.
I believe that (though I haven't tested them) all browsers understand
the assignment of - null - to the element's onclick property (and other
event handling properties) as sufficient to disable a handler. The
support of - null - should include all language versions.
function someFunction() {
this.onclick = function() {return true;};
}
Neither of the proposed methods will work because the - someFunction -
function is not the event handling method, it is just a function called
by that method, so the - this - keyword will not refer to the element
(it will refer to the global object).
It may also not be a good idea for the execution of - someFunction - to
form a closure, so the assignment of a harmless dummy function may be
better not done with an inner function expression.
<div ... onClick="someFu nction();this.o nclick = null;">
- or (assigning a harmless dummy function):-
<script type="text/javascript">
function retTrue(){ return true; }
function someFunction(){
...
}
</script>
<div ... onClick="someFu nction();this.o nclick = retTrue;">
Richard.