addLoadEvent函数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了addLoadEvent函数相关的知识,希望对你有一定的参考价值。

Description: Execute different functions when the page loads in a better way than default onload JS event. Include it in the end of the JS document.
Arguments: Name of the function that you want to execute when the page loads.
Author: Simon Willison
  1. function addLoadEvent(func) {
  2. var oldonload = window.onload;
  3. if (typeof window.onload != 'function') {
  4. window.onload = func;
  5. } else {
  6. window.onload = function() {
  7. oldonload();
  8. func();
  9. }
  10. }
  11. }

以上是关于addLoadEvent函数的主要内容,如果未能解决你的问题,请参考以下文章

addLoadEvent函数

addLoadEvent函数

onload事件-----addLoadEvent函数

addLoadEvent.js 不管在页面加载完毕执行多少个函数,都应付自如

JavaScript addLoadEvent

JavaScript addLoadEvent