HTML onload 이벤트 속성은 객체가 HTML 문서에 로드될 때 트리거됩니다.
구문
다음은 구문입니다 -
<tagname onload=”script”></tagname>
HTML onload 이벤트 Attribute의 예를 살펴보겠습니다-
예시
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
text-align: center;
padding: 20px;
}
</style>
<script>
function get() {
alert("Hi! you just refresh the document.");
}
</script>
</head>
<body onload="get()">
<h1>HTML onload Event Attribute Demo</h1>
<p style="color:#db133a;">Now try to refresh this document.</p>
</body>
</html> 출력

이제 문서를 다시 로드하여 onload 이벤트 속성이 작동하는 방식을 관찰하십시오.
