Matt Fiddles

Life's so vast, there's just so much to do...

User Tools

Site Tools


Sidebar

"I find your lack of faith disturbing."

- Darth Vader



Where will you go today?

ARTHUR It's not a question of whose habitat it is, it's a question of how hard you hit it.

- Arthur pointing out one of the disadvantages of gravity, Fit the Tenth.
computers:websites:javascript-scriplets

Javascript Scriptlets

Multiple Onload Events

This is a better way to load multiple onload events, so previous ones aren't erased.

From http://www.webreference.com/programming/javascript/onloads/index.html

<script type="text/javascript">
// from http://simonwillison.net/
// so multiple onload events work together
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(
    function_to_run()
);
</script>
computers/websites/javascript-scriplets.txt · Last modified: Jun 14, 2014 (4 years ago) by Matt Bagley