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

前端 未结 5 1217
傲寒
傲寒 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:18

    You should use the onload function because you will come across less problems when trying to debug it in different browsers.

    The only other way I know to simulate this effect reliably is to have a script tag block just before the at the footer of the page.

提交回复
热议问题