Monday, 9 October 2017

javascript - How to know when page is ready without using jQuery (alternative way)?

itemprop="text">











If
you have jQuery called in your page. You can simply do
it:




$(document).ready(function()
{ /** code inside
**/});


But how to do
similar thing without jQuery?


itemprop="text">
class="normal">Answer



You can
use the DOMContentLoaded
event.



document.addEventListener('DOMContentLoaded',
function() {
//
...

});


Note
that in older IEs you need workarounds, some use the
readystatechange event if I recall
correctly.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...