Window.load Doesn't Fire Always On Chrome?
I have this userscript: // ==UserScript== // @name test // @namespace test // @description show's an alert on load // @include http://* // @include https
Solution 1:
The cause of the problem is that the Content script is sometimes executed when the document has already fully loaded. This is illustrated using the following Content script ("User Script"):
// ==UserScript==// @name Test// @namespace Test// @include *// ==/UserScript==window.addEventListener('load', function(){alert("loaded");}, false);
alert(document.readyState); // When this prints "complete", onload never runs
To solve the issue, use the @run-at document-start
meta-rule, which causes the script to execute before the document is created:
...
// @run-at document-start// ==/UserScript==
Post a Comment for "Window.load Doesn't Fire Always On Chrome?"