Reputation: 770
I use content script in my Chrome extension. content scripts are injected at "document_start".
window.onload = function() {console.log("window onload event fired.");}
I run the above code in content script, but when I load a page, the onload event is not fired.
Is there anything wrong?
Upvotes: 9
Views: 11678
Reputation: 243
Check with this Code
if (window.attachEvent) {window.attachEvent('onload', your_function);}
else if (window.addEventListener) {window.addEventListener('load', your_function, false);}
else {document.addEventListener('load', your_function, false);}
Upvotes: 3
Reputation: 5191
It's working perfectly.In order to check whether the console.log
is fired or not on windows onload event.
Run(Load
) the Page/Script in Chrome.
Right click
and select Inspect element
.
Click on Console tab
.
You will see "window onload event fired.
" on console box.
Screen Shot:
Upvotes: -2