[Javascript] weird FX event model

Troy III Ajnej trojani2000 at hotmail.com
Sat May 3 13:26:36 CDT 2008


I have e function like this:
 
function onmouseover(e){        if(!e) {e=event.srcElement}                else {e=e.target}                var type = e.getAttribute('type')
                var monitor=document.getElementById("monitor")        if(type){                monitor.innerHTML+= '<br>this element type is: '+ type}
                }
 
document.onmouseover = onmouseoverWhat this function does is that it identifies the element that fired the
 
onmouseover event
 
than it checks if the element has a defined "type" attribute, if it does
than it writes the value of the type attribute into the element named
monitor.
 
The problem with this function is that FX is triggering the event twice,
causing two calls per event to the function.
 
Odly enough, I was forced to assign the id of the element to the var:
 
                var monitor=document.getElementById("monitor")
Otherwise
I get error: "monitor is not defined"! Not the usual:"element referenced 
by name/id, you should use standard bla bla bla...".
 
This error should not relate to the problem causing the double call of the
function. But there it is!
 
As it turns out I understand that it is not the statement:
document.onmouseover = onmouseover
that causes the problem, but the name of the function itself. 
 
This means that you can use a never seen before syntax:
 
function onclick(){alert ("I must have clicked somewhere")}
 
And it will work!!!
 
After discovering this weird hybrid (event-function) object, I've managed 
to eliminate the double function call by changing the name of the function, 
naturally, but what do you call it? Is it some sort of a proprietary shorthand 
scripting routine I never seen before, or what?
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                        Troy III                            progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_________________________________________________________________
Stay in touch when you're away with Windows Live Messenger.
http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_messenger_052008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20080503/d78cda8f/attachment.htm>


More information about the Javascript mailing list