mirror of
https://github.com/jonom/silverstripe-betternavigator.git
synced 2024-10-22 14:05:51 +02:00
Use addEventListener to schedule BN initialisation only if document is still loading
This commit is contained in:
parent
2a9df8695d
commit
a686f4d517
@ -32,13 +32,13 @@ function initialiseBetterNavigator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.addEventListener) {
|
if (document.addEventListener && document.readyState === 'loading') {
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
//wait til DOM is ready
|
// wait til DOM finishes loading
|
||||||
initialiseBetterNavigator();
|
initialiseBetterNavigator();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//This is the case for IE8 and below
|
// This is the case for IE8 and below OR already loaded document (e.g. when using async)
|
||||||
//initialise straight away - fine if script is loaded after BN dom element
|
// initialise straight away - fine if script is loaded after BN dom element
|
||||||
initialiseBetterNavigator();
|
initialiseBetterNavigator();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user