window.onload与document.onload

window.onload与document.onload

得到了更广泛的支持:window.onloaddocument.onload?


ibeautiful
浏览 1692回答 4
4回答

郎朗坤

添加事件侦听器<script&nbsp;type="text/javascript"> &nbsp;&nbsp;document.addEventListener("DOMContentLoaded",&nbsp;function(event)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;-&nbsp;Code&nbsp;to&nbsp;execute&nbsp;when&nbsp;all&nbsp;DOM&nbsp;content&nbsp;is&nbsp;loaded.&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;-&nbsp;including&nbsp;fonts,&nbsp;images,&nbsp;etc. &nbsp;&nbsp;});</script>Update March 20171香草JavaScriptwindow.addEventListener('load',&nbsp;function()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log('All&nbsp;assets&nbsp;are&nbsp;loaded')})2 jQuery$(window).on('load',&nbsp;function()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;console.log('All&nbsp;assets&nbsp;are&nbsp;loaded')})祝好运。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript