Sử dụng onload để thực thi một tập lệnh khi phần tử được tải xong.
Ví dụ
Bạn có thể thử chạy mã sau để triển khai thuộc tính 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>