Click here to Skip to main content
15,795,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone. I am simply trying to build a Chrome extension which waits for a webpage to load then, gets access to its DOM model an finally manages to modify it by injecting scripts at certain parts of the page. The extension is meant to be a page_action since i am planning to run it on certain websites. I don't need a pop_up or anything. Just an extension that would run in the background without the user having to push any buttons or click on any pop ups.

The current problem I am facing right now is that, the functions are called BEFORE the DOM is completely loaded. Is there a way for me to wait till the DOM is completely loaded then, perform my modifications?

Thank you in advance!
Updated 11-Feb-13 1:40am

1 solution

I finally managed to reach a solution which fits my case. I added the following line of code to my .js file.
$(window).bind('hashchange', fooBar);

This way, everytime the URL of the page changes, the function fooBar is called. This event is only triggered after the page's DOM is completely loaded.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900