add onload.js to 2.3 branch, for mac addresses, RT#27190, RT#26013
[freeside.git] / httemplate / elements / onload.js
diff --git a/httemplate/elements/onload.js b/httemplate/elements/onload.js
new file mode 100644 (file)
index 0000000..c7bbbb2
--- /dev/null
@@ -0,0 +1,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);
+  }
+})();