JavaScript detect changes to document.title
Detect changes to document.title using JavaScript.
Javascript
var target = document.querySelector('title'); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { console.log('title changed to "%s"', document.title); }); }); var config = { childList: true, }; observer.observe(target, config);
Full example:
HTML
<html> <head> <title>My Page Title</title> </head> <body> <script> var target = document.querySelector('title'); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { console.log('title changed to "%s"', document.title); }); }); var config = { childList: true, }; observer.observe(target, config); setTimeout(function() { document.title = 'New page title'; }, 5000); </script> </body> </html>
Tip BCH: qrt9edpnmmr65xsnd3xdlfa0r6rpt36rfqrevu6h54
Tip BTC: 1NX28KTAVbeWai4UFqJZXYDMMpr6SwLYCw
Tip ETH: 0x53bEc9317d97a7BEBD68957A87C39EA54cD20a48
Tip LTC: LhDAkf1MLRepNe9PUuuJSPuAvx8GHqA1ed