PageSourceSearch

https://www.shearerpainting.com/Scripts/runonload.js

js shearerpainting.com collected 2026-09-24 19:42:00 UTC 2,277 bytes, 48 lines download raw bytes

1/*
2 * runOnLoad.js: portable registration for onload event handlers.
3 * 
4 * This module defines a single runOnLoad() function for portably registering
5 * functions that can be safely invoked only when the document is fully loaded
6 * and the DOM is available.
7 *
8 * Functions registered with runOnLoad() will not be passed any arguments when
9 * invoked. They will not be invoked as a method of any meaningful object, and
10 * the this keyword should not be used.  Functions registered with runOnLoad()
11 * will be invoked in the order in which they were registered.  There is no
12 * way to deregister a function once it has been passed to runOnLoad().
13 *
14 * In old browsers that do not support addEventListener() or attachEvent(),
15 * this function relies on the DOM Level 0 window.onload property and will not
16 * work correctly when used in documents that set the onload attribute
17 * of their <body> or <frameset> tags.
18 */
19function runOnLoad(f) {
20    if (runOnLoad.loaded) f();    // If already loaded, just invoke f() now.
21    else runOnLoad.funcs.push(f); // Otherwise, store it for later
22}
23
24runOnLoad.funcs = []; // The array of functions to call when the document loads
25runOnLoad.loaded = false; // The functions have not been run yet.
26
27// Run all registered functions in the order in which they were registered.
28// It is safe to call runOnLoad.run() more than once: invocations after the
29// first do nothing. It is safe for an initialization function to call
30// runOnLoad() to register another function.
31runOnLoad.run = function() {
32    if (runOnLoad.loaded) return;  // If we've already run, do nothing
33
34    for(var i = 0; i < runOnLoad.funcs.length; i++) {
35        try { runOnLoad.funcs[i](); }
36        catch(e) { /* An exception in one function shouldn't stop the rest */ }
37    }
38    
39    runOnLoad.loaded = true; // Remember that we've already run once.
40    delete runOnLoad.funcs;  // But don't remember the functions themselves.
41    delete runOnLoad.run;    // And forget about this function too!
42};
43
44// Register runOnLoad.run() as the onload event handler for the window
45if (window.addEventListener)
46    window.addEventListener("load", runOnLoad.run, false);
47else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
48else window.onload = runOnLoad.run;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.