@manhnguyenv

Welcome to my blog!

JavaScript in ASP.NET

December 5, 2018 15:34

JavaScript in ASP.NET (edit)

document.getElementById returns null in my javascript code

Rion Williams

function work() { /*...*/ }

if (document.readyState == 'loading') {
  document.addEventListener('DOMContentLoaded', work);
} else {
  work();
}

setTimeout

var delayInMilliseconds = 1000; //1 second

setTimeout(function() {
  //your code to be executed after 1 second
}, delayInMilliseconds);

How To Decide When Your Code Should Run

https://eager.io/blog/how-to-decide-when-your-code-should-run/

Page lifecycle: DOMContentLoaded, load, beforeunload, unload

https://javascript.info/onload-ondomcontentloaded

Categories

Recent posts