首页 > Web开发 > 详细

网页加载完成后再执行代码

时间:2018-07-15 10:46:08      阅读:149      评论:0      收藏:0      [点我收藏+]
<!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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!