views:

18

answers:

1

Hi all, I am developing an extension from Chrome and I need to do some changes to the page code after it is loaded. but the problem is window.onload event isn't useful nowadays where almost any website is using AJAX. You can't assume that all content is already loaded because window.onload is fired before all AJAX request has done loading. So I want to be able to capture all the onreadystatechange belonging to any XMLHttpRequest and handle that event in my extension ..... is this even possible ? do prototypes help here ?

A: 

I don't believe it's directly possible, though perhaps you could replace window.XMLHttpRequest with your own object that acted as a proxy to a real XMLHttpRequest (but feeding global callbacks to your own code).

But you can't really assume that an XMLHttpRequest is anything to do with content loading anyway. A script might write a load of content on any interaction event or even an unprovoked timeout.

If you need to know any time new content is added to the document, you probably need DOM Mutation Events.

bobince