window.onload与document.onload得到了更广泛的支持:window.onload或document.onload?
4 回答
郎朗坤
TA贡献1921条经验 获得超9个赞
添加事件侦听器
<script type="text/javascript"> document.addEventListener("DOMContentLoaded", function(event) { // - Code to execute when all DOM content is loaded. // - including fonts, images, etc. });</script>
Update March 2017
1香草JavaScript
window.addEventListener('load', function() { console.log('All assets are loaded')})
2 jQuery
$(window).on('load', function() { console.log('All assets are loaded')})
添加回答
举报
0/150
提交
取消