Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] To DOM or not -- calendar popup
- From: moseley at hank.org (Bill Moseley)
- Subject: [Javascript] To DOM or not -- calendar popup
- Date: Wed Mar 29 23:25:59 2006
On Wed, Mar 29, 2006 at 02:43:26PM -0500, Matt Warden wrote:
> It's not that bad. Something like:
>
> if (document.getElementById && document.createElement) {
> var field = document.getElementById('whatever');
> if (field) {
> var img = document.createElement('img');
> img.src = 'whatever.foo';
> img.onclick = calPopupFunction;
> field.parentNode.appendChild(img);
> }
> }
Thanks. Yes, not bad at all.
Another thing that has been burning a hole in my to-ask file is what's
the difference between using img.onclick above vs. using
addEventListner/attachEvent -- besides being able to attach more than
one event. Are there times when one is more appropriate? Or are they
basically the same thing?
Prototype has Event.observe which uses those methods to attach
events, and also tracks the event for unloading -- IIRC one (the?)
reason that's done is to prevent memory leaks in IE.
--
Bill Moseley
moseley@xxxxxxxx
- Follow-Ups:
- [Javascript] To DOM or not -- calendar popup
- From: Matt Warden
- [Javascript] To DOM or not -- calendar popup
- References:
- [Javascript] To DOM or not -- calendar popup
- From: Bill Moseley
- [Javascript] To DOM or not -- calendar popup
- From: Matt Warden
- [Javascript] To DOM or not -- calendar popup
- Prev by Date: [Javascript] dom question
- Next by Date: [Javascript] To DOM or not -- calendar popup
- Previous by thread: [Javascript] To DOM or not -- calendar popup
- Next by thread: [Javascript] To DOM or not -- calendar popup
- Index(es):