Add two functions to window.onload - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window Load

Description

Add two functions to window.onload

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
Function.prototype.extend = function(fn) {
  var self = this;//w w w.j  av a  2s  .  c o m
  return function(){
    self.apply(this, arguments);
    fn.apply(this, arguments);
  };
};
window.onload = function() {
  console.log('foo');
};
window.onload = window.onload.extend(function() {
  console.log('bar');
});

      </script>  
   </body>
</html>

Related Tutorials