Matt Fiddles

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

User Tools

Site Tools


Sidebar

"`You know they've reintroduced the death penalty for insurance company directors?'
`Really?' said Arthur. `No I didn't. For what offence?'
Trillian frowned.
`What do you mean, offence?'
`I see.'"

- Evidence that there will be some justice in the Universe eventually.



Where will you go today?

Luke Skywalker: "Alright, I'll give it a try."

Yoda: "No! Try not. Do... or do not. There is no try."
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