summaryrefslogtreecommitdiff
path: root/httemplate/elements/onload.js
blob: c7bbbb2832e59709722da66d19c6bbb4f5ed641a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<%doc>
Filter component to attach a window.onload handler.

Usage:
  <script>
  <&| elements/onload.js &>
    if ( the_stars_are_right ) {
      run_this_function();
    }
  </&>
  </script>

</%doc>
(function() {
  var myonload = function() {
<% $m->content %>
  }
  if ( window.addEventListener ) {
    window.addEventListener('load', myonload);
  } else if ( window.attachEvent ) {
    window.attachEvent('onload', myonload);
  }
})();