What is the DOM ready event?

前端 未结 5 1548
攒了一身酷
攒了一身酷 2020-12-01 09:29

I need to fire a script as soon as the page content (the whole HTML element) has been received, but it doesn\'t have to be rendered yet.

I assume that just having a

5条回答
  •  庸人自扰
    2020-12-01 10:33

    You might also try with the functions

    window.onload = function(){
       //your code
      }
    

    or

    body.onload = function(){
       //your code
      }
    

    if you don't want to use jQuery.

    Be careful though, DOM loaded doesn't mean the page loaded, iframes, javascript, images and css might load after that event.

    There is a good tuto on DOM events Javascript tutorial

提交回复
热议问题