<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>Planets</title> ???<script> ???????//网页加载完成后再执行代码 ???????function init (){ ???????????var planet = document.getElementById("greenplanet"); ???????????planet.innerHTML = "Red alert: hit by phase fire!"; ???????} ???????window.onload = init; ???</script></head><body> ???<h1>Green Planet</h1> ???<p id="greenplanet">All is well</p> ???<h1>Red planet</h1> ???<p id="redplanet">Nothing to report</p> ???<h1>Blue planet</h1> ???<p id="blueplanet">All system A-OK</p></body></html>
网页加载完成后再执行代码
原文地址:https://www.cnblogs.com/themost/p/9311916.html