HTML Event attribute: onload
[this page | pdf | back links]
The HTML onload attribute specifies the event
that is triggered when an element finishes loading. It applies to <body>, <iframe>, <img>, <input>, <link>, <script> and <style> elements.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body onload="myOnload()">
onload: <span id="element"></span>
<script>
function myOnload() {
var x = document.createElement("B");
var txt = document.createTextNode("bold text added by onload");
x.appendChild(txt);
document.getElementById("element").appendChild(x);
}
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes