Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> </head> <body> <iframe id="iframe" src="/" ></iframe> <script> let oldDocs = iframe.contentDocument; // every 100 ms we check if the document is new let timer = setInterval(() => { let newDocs = iframe.contentDocument; if (newDocs == oldDocs) return; alert("New document is here"); clearInterval(timer); // cancel setInterval, no longer needed }, 500); </script> </body> </html>