Javascript: What argument calls the function specified in the body's onload event?

As in this question, my HTML looks like this:

<body id="body" onload="loader()"> </body> 

I always assume that this document says there are no arguments in onload. However, I called this argument and did a deep check, and found that I have an object similar to this:

 {originalTarget : DOM, preventCapture : function, target : DOM, cancelable : Bool, currentTarget : DOM, timeStamp : Int, bubbles : Bool, type : String, eventPhase : Int, preventDefault : function, initEvent : function, stopPropagation : function, CAPTURING_PHASE : Int, AT_TARGET : Int, BUBBLING_PHASE : Int, explicitOriginalTarget : DOM, preventBubble : function, isTrusted : Bool, MOUSEDOWN : Int, MOUSEUP : Int, MOUSEOVER : Int, //... (more constants) } 

Does anyone know what it is, or what could be its class name?

+7
javascript dom browser firefox events
source share
1 answer

This is similar to the standard JavaScript DOM Event object. It describes the nature of the event that your function processes.

UPDATE In response to a discussion of comments:

Different browsers provide an Event object in different ways:

  • IE never passes it as an argument to a function and instead uses the window.event property.
  • Firefox will pass it as the first argument.
  • Chrome seems to be doing both.
+9
source share

All Articles