-4

Tried searching a lot.
could not find any solutions for onchange of page title.

There is jQuery .change() but that is limited to "input elements, textarea boxes and select elements."

What I am trying is to give an alert whenever any script changes the title of the page.

I am building a Chrome extension that alerts the user when the document.title has changed.

Neil
  • 402
  • 6
  • 18

1 Answers1

4

Here is a plugin, I suppose:

$.fn.titleChange = function(origTitle,callback){      
   setInterval(function(){
     if(origTitle == document.title){
        return false;
     }
     else {
       callback();
       origTitle = document.title;
     }
   },1000);
}

Use the above like this:

$(function(){
  $(document).titleChange(document.title,function(){alert("changed");});
});
Amit Joki
  • 58,320
  • 7
  • 77
  • 95