Skip to Content

JavaScript File

URL: https://www.w3.org/WAI/demos/bad/js/onload.js
HTTP Status: 200 OK
MIME Type: text/javascript
Last Modified: Thu, 26 Jan 2012 09:01:50 GMT
Download Time: Less than a second
Cookies: __cf_bm=FpRt7NSGkioC4dVvJa9P9
Size: 1 KB
HTTP Headers:  16 headers
Links In:  6 pages
OK Issues: No issues found

1/*

2* Multiple onload events

3* By Simon Willison

4* http://simonwillison.net/2004/May/26/addLoadEvent/

5*

6*/

7function addLoadEvent(func) {

8 var oldonload = window.onload;

9 if (typeof window.onload != 'function') {

10 window.onload = func;

11 }

12 else {

13 window.onload = function() {

14 if (oldonload) {

15 oldonload();

16 }

17

18 func();

19 }

20

21 }

22

23}