Similar to this question, my HTML looks like this:
<body id="body" onload="loader()">
</body>
I always assume, as this doc says, that onload is given no arguments. However, I named the argument, and did some deep inspection, and found that I got an object looking like 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)
}
Anyone have any idea what that thing is, or what its classname might be?
The onload attribute fires when an object has been loaded. onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.). However, it can be used on other elements as well (see "Supported HTML tags" below).
In JavaScript, this event can apply to launch a particular function when the page is fully displayed. It can also be used to verify the type and version of the visitor's browser. We can check what cookies a page uses by using the onload attribute.
The first approach for calling a function on the page load is the use an onload event inside the HTML <body> tag. As you know, the HTML body contains the entire content of the web page, and when all HTML body loads on the web browser, it will call the function from the JavaScript.
The onload property processes load events after the element has finished loading. This is used with the window element to execute a script after the webpage has completely loaded. The function that is required to be executed is assigned as the handler function to this property.
That appears to be the standard JavaScript DOM Event object. It describes the nature of the event that your function is handling.
UPDATE In response to comment discussion:
Different browsers supply the Event object in different ways:
window.event
property.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With