[Javascript] weird FX event model
Roger Roelofs
rer at datacompusa.com
Sat May 3 22:22:40 CDT 2008
Troy,
Troy III Ajnej wrote:
> I have e function like this:
>
> function onmouseover(e){
> -------------8<----------------
> 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?
I could be wrong, but my understanding is that everything in Javascript
is associated with an object. In a browser environment, window is the
top-level object, so all functions and variables that appear to be
top-level items actually are properties and methods of the window
object. If that is true, then
function onmouseover(e) {} is the same as
window.onmouseover = function(e) {}
So, the behavior you are seeing is the behavior I would have expected.
hth
Roger
--
Roger Roelofs
Datacomp Appraisal Services
3215 Eaglecrest, NE E: rer at datacompusa.com
Grand Rapids, MI 49525 W: http://www.datacompusa.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20080503/b95ba981/attachment.htm>
More information about the Javascript
mailing list