एलिमेंट की लोडिंग समाप्त होने पर स्क्रिप्ट निष्पादित करने के लिए onload एट्रिब्यूट का उपयोग करें।
उदाहरण
onload एट्रिब्यूट लागू करने का कोड:
<!DOCTYPE html>
<html>
<head>
<script>
function display() {
alert("Welcome!");
}
</script>
</head>
<body onload="display()">
<h3>Welcome to the website.</h3>
<p>We offer learning content.</p>
</body>
</html>
onload इवेंट <body> पर सबसे आम है (पेज पूरी तरह लोड होने पर)। इसका उपयोग <img>, <script>, <iframe> आदि पर भी किया जा सकता है।