Start processing on DOMContentLoaded, if possible, and check document.readyState to see if the onload handler has already fired (avoids the need for authors to call MathJax.Hub.Startup.onload() by hand)

This commit is contained in:
Davide P. Cervone 2011-09-06 21:05:51 -04:00
parent 3717fcfb57
commit 53fc357cfc
2 changed files with 7 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -1809,7 +1809,12 @@ MathJax.Hub.Startup = {
onLoad: function (when) {
var onload = this.onload =
MathJax.Callback(function () {MathJax.Hub.Startup.signal.Post("onLoad")});
if (window.addEventListener) {window.addEventListener("load",onload,false)}
if (document.readyState && document.readyState !== "loading") {return [onload]}
if (window.addEventListener) {
window.addEventListener("load",onload,false);
if (!this.params.noDOMContentEvent)
{window.addEventListener("DOMContentLoaded",onload,false)}
}
else if (window.attachEvent) {window.attachEvent("onload",onload)}
else {window.onload = onload}
return onload;