Running javascript code on page load, without using the onload tag

前端 未结 5 1223
傲寒
傲寒 2020-12-18 10:33

How can I run a JavaScript code when the page loads without using the onload tag?

I\'m trying to run this script:



        
5条回答
  •  没有蜡笔的小新
    2020-12-18 11:00

    Note that commands outside of functions in a script tag in the header run when the page loads. I don't know if this is actually equivalent to running functions explicitly onLoad via the body tag attribute, but it is tantamount to the same thing.

提交回复
热议问题