usually I would have assigned a method name to the function and defined the document.onclick like this:
document.onclick = mySpecialFunction(this);
<script> function mySpecialFunction(event){... // not sure whether this matters though..
then I've also found that the method should return true/false, or if its MSIE you have to set the event.returnValue = false/true, depending if you want the event to bubble up to the other listeners... (NB! havn't checked the previous syntax)
Since event model seems to be different from browser to brower it seems safest to pass the event object around- unless you are building a MSIE only application.
Also maybe consider attaching your specific listener to only the part of the document that you need to it -- eg an enclosing div... ? C
On 10/23/06,
Bertram Julius <[EMAIL PROTECTED]> wrote:
try attachEvent and detachEvent..............
Bertram.
-----Original Message-----
From: [email protected]
[mailto: [email protected]]On Behalf Of Ryan Meder
Sent: 23 October 2006 02:41
To: [email protected]
Subject: [CTJUG Forum] JS Document event listeners
Hi,
I have a _javascript_ question:
I am adding event listeners to events by making use of the following method.
document.onclick = function (oEvent) {
var o = document.getElementById ("wpQuickEntryAdd");
if(o){
o.parentNode.removeChild(o);
}
}
Whenever I click on the document this method is called. Which is
correct. My problem is that I include many library's which contain the
same method. what _javascript_s seems to do is overrright the the
previous onclick event listener with the last one that is loaded.
Does anybody know of a way to solve this. I think the anwers is on the
lines that you must be able to add multiple event listeners on the
document maby an array or somthing
--
Regards,
Ryan Meder
This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this e-mail in error please notify NSFAS immediately. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the organisation.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
-~----------~----~----~----~------~----~------~--~---
