I inherited this piece of code and it seems suboptimal and possibly incorrect since it\'s adding event listeners on both the window and document objects. However, it is wor
Personally I'd use jQuery for this.
jQuery is designed to handle the variety of different browser implimentations of the document ready state.
Using jQuery your above code would look like:
$(callback);