Running javascript after page is fully rendered

后端 未结 4 648
一向
一向 2020-12-03 10:40

I am trying to create a syntax highlighter script. I tried using my script on a code with 10 thousand lines and all I see is a blank page while it is loading. Everything wil

4条回答
  •  执笔经年
    2020-12-03 11:11

    Do you mean after all the images have been loaded?

    I think window.onload is what you're looking for

    window.onload = function() {
        //dom not only ready, but everything is loaded
    };
    

    EDIT

    Per Chris's comment, here's the jQuery way:

    $(window).load(function() {
        //dom not only ready, but everything is loaded
    });
    

提交回复
热议问题