Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window onload event not fired in chrome content script

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?

like image 648
Leslie Wu Avatar asked Mar 27 '13 05:03

Leslie Wu


1 Answers

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);}
like image 160
Baalu Avatar answered Oct 19 '22 23:10

Baalu