pageshow-pagehide-example.html 765 B

1234567891011121314151617181920212223242526272829
  1. <html>
  2. <head>
  3. <script>
  4. function pageShown(evt)
  5. {
  6. if (evt.persisted)
  7. alert("pageshow event handler called. The page was just restored from the Page Cache.");
  8. else
  9. alert("pageshow event handler called for the initial load. This is the same as the load event.");
  10. }
  11. function pageHidden(evt)
  12. {
  13. if (evt.persisted)
  14. alert("pagehide event handler called. The page was suspended and placed into the Page Cache.");
  15. else
  16. alert("pagehide event handler called for page destruction. This is the same as the unload event.");
  17. }
  18. window.addEventListener("pageshow", pageShown, false);
  19. window.addEventListener("pagehide", pageHidden, false);
  20. </script>
  21. <body>
  22. <a href="http://www.webkit.org/">Click for WebKit</a>
  23. </body>
  24. </html>