代码示例:(标识:eg_js_events_onload_body)
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
  alert("页面已加载");
}
</script>
</head>

<body onload="myFunction()">
<h2>Hello World!</h2>
</body>

</html>
运行结果: