Guest User

Untitled

a guest
Mar 26th, 2020
96
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. console.log('document.readyState initial:', document.readyState);
  3.  
  4. // Try event after document is loaded (from https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)
  5. window.onload = (event) => {
  6.   console.log('document.readyState after window.onLoad:', document.readyState);
  7. };
  8. window.addEventListener('load', (event) => {
  9.   console.log('document.readyState after window.addEventListener(load):', document.readyState);
  10. });
  11. document.addEventListener('DOMContentLoaded', (event) => {
  12.   console.log('document.readyState after document.addEventListener(DOMContentLoaded):', document.readyState);
  13. });
  14.  
  15. // Document readychange
  16. document.addEventListener('readystatechange', (event) => {
  17.   console.log('document.readyState changed:', document.readyState);
  18. });
  19.  
  20. // Log after 5 seconds
  21. setTimeout(() => {
  22.   console.log('document.readyState after 5s:', document.readyState);
  23. }, 5000);
  24.  
  25. // Log after user has clicked
  26. window.addEventListener('click', function() {
  27.   console.log('document.readyState after a click:', document.readyState);
  28. });
  29. </script>
RAW Paste Data