| 
	
 | 
 Posted by Toby Inkster on 06/25/06 10:09 
Jonathan N. Little wrote: 
 
> e = document.getElementById('me2'); 
> e.onclick=cancelIt; 
> [...] 
> Ok, effect, not hard coded, but does not append but replace handlers 
> <br><input type="submit" value="Direct Dot Coded" id="me2"> 
 
I've never been a fan of addEventListener and generally use the method 
above. Of course, with the code you've used, you'll stomp over any 
existing e.onclick function. The solution is along these lines: 
 
	var oldfunc = e.onclick; 
	if (typeof e.onclick != 'function') 
		e.onclick = cancelIt; 
	else  
		e.onclick = function() 
		{ 
			oldfunc(); 
			cancelIt(); 
		} 
 
 
--  
Toby A Inkster BSc (Hons) ARCS 
Contact Me  ~ http://tobyinkster.co.uk/contact
 
  
Navigation:
[Reply to this message] 
 |