Search code examples
javascriptajaxuserscripts

running my code when other function called Javascript


I am writing a user script (for greasemonkey) to a website. This website uses Ajax to change the HTML without reloading, and i want to add some buttons every time the page changes. The function that does it called "ajaxHandlerCall".

Is there a way to load my function every time this function called? ("event" of calling the function)

Thanks.


Solution

  • You may be able to do something like:

    var oldHandler = ajaxHandlerCall;
    ajaxHandlerCall = function(event){
        /* do Stuff */
        oldHandler (event);
    }
    

    Basically, you're wrapping the old handler in a function of your own.