1. (function() {
  2. // Function to execute a function with a delay
  3. function executeWithDelay(func, delay) {
  4. setTimeout(func, delay);
  5. }
  6. // Function to monitor for changes in the document's state
  7. function monitorDocument() {
  8. // Function to execute when the document is ready
  9. function onDocumentReady() {
  10. console.log("Document is ready.");
  11. // Execute your code here. Replace with your desired actions.
  12. // Example: document.body.style.backgroundColor = "lightblue";
  13. }
  14. // Function to execute when the document is fully loaded
  15. function onDocumentLoad() {
  16. console.log("Document is loaded.");
  17. // Execute your code here. Replace with your desired actions.
  18. //Example: alert("Document Loaded");
  19. }
  20. // Listen for the 'DOMContentLoaded' event
  21. document.addEventListener('DOMContentLoaded', onDocumentReady);
  22. // Listen for the 'load' event (for images, scripts, etc.)
  23. window.addEventListener('load', onDocumentLoad);
  24. }
  25. // Start monitoring the document
  26. monitorDocument();
  27. })();

Add your comment