W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>本例使用 HTML DOM 将 "onpageshow" 事件分配给 body 元素。</p> <p><b>注释:</b>Internet Explorer 10 及更早版本不支持 onpageshow 事件。</p> <h1 id="demo"></h1> <script> document.getElementsByTagName("BODY")[0].onpageshow = function() {myFunction()}; function myFunction() { document.getElementById("demo").innerHTML = "Welcome To My Homepage!"; }; /* This is equivalent to assigning the event to the window object: window.onpageshow = function() { document.getElementById("demo").innerHTML = "Welcome To My Homepage!"; }; */ </script> </body> </html>