EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

load | onload event

Fires immediately after the client loads the object.

HTML 4.01 Specification, Section 18.2.3

 

Syntax

HTML Attribute <element onload = "handler(event)">
Event Property object.onload = handler;
attachEvent Method object.attachEvent("onload", handler)
addEventListener Method object.addEventListener("load", handler, useCapture)

 

Event information

SynchronousNo
BubblesNo
CancelableNo

 

Event handler parameters

pEvtObj [in]

Type: IHTMLEventObj

Standards information

Remarks

The client loads applications, embedded objects, and images as soon as it encounters the applet, embed, and img objects during parsing. Consequently, the onload event for these objects occurs before the client parses any subsequent objects. To ensure that an event handler receives the onload event for these objects, place the script object that defines the event handler before the object and use the onload attribute in the object to set the handler.

The onload attribute of the body object sets an onload event handler for the window. This technique of calling the window onload event through the body object is overridden by any other means of invoking the window onload event, provided the handlers are in the same script language.

Loads the object for which the event is specified.

To invoke this event, do one of the following:

  • Open a document to invoke this event for the document or any object within it.

The pEvtObj parameter is required for the following interfaces:

Examples

The following example shows how to declare an onload event for a document that is designed to work with multiple browsers and earlier versions of Internet Explorer.


<!doctype html>
<head>
  <title>Load Event Sample</title>
  <script type="text/javascript">
  function doLoad() {
     alert( "The load event is executing" );
  }
  if ( window.addEventListener ) { 
     window.addEventListener( "load", doLoad, false );
  }
  else 
     if ( window.attachEvent ) { 
        window.attachEvent( "onload", doLoad );
  } else 
        if ( window.onLoad ) {
           window.onload = doLoad;
  }
  </script>
</head>
<body>
  <h1>Load Event Sample</h1>
  <p>This sample demonstrates how to execute 
     an event while the document is loading.</p>
</body>
</html>

See also

a
abbr
acronym
address
applet
area
audio
b
base
baseFont
bdo
bgSound
big
blockQuote
body
br
button
canvas
caption
center
cite
code
col
colGroup
comment
custom
dd
del
dfn
dir
div
dl
document
dt
em
embed
fieldSet
font
form
frame
frameSet
head
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
ins
isIndex
kbd
label
legend
li
link
listing
map
marquee
media
menu
meta
nextID
noBR
noFrames
noScript
object
ol
optGroup
option
p
param
plainText
pre
q
rt
ruby
s
samp
script
select
small
source
span
strike
strong
style
sub
sup
SVGSVGElement
table
tBody
td
textArea
tFoot
th
tHead
title
tr
tt
u
ul
var
video
wbr
window
xmp
Reference
onreadystatechange
onunload

 

 

Afficher:
© 2014 Microsoft