You are here: Re: event handler attachment « HTML « IT news, forums, messages
Re: event handler attachment

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация