运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <p>Use the HTML DOM to assign an "onpageshow" event to a body element.</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>