How to make JavaScript execute after page load?

前端 未结 24 2400
孤城傲影
孤城傲影 2020-11-21 05:55

I\'m executing an external script, using a

24条回答
  •  闹比i
    闹比i (楼主)
    2020-11-21 06:03

    Using the YUI library (I love it):

    YAHOO.util.Event.onDOMReady(function(){
        //your code
    });
    

    Portable and beautiful! However, if you don't use YUI for other stuff (see its doc) I would say that it's not worth to use it.

    N.B. : to use this code you need to import 2 scripts

    
    
    

提交回复
热议问题