元素加载完成后,请使用 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>