Comment

Peter Bengtsson

Are you sure, isn't window.onload always an object?

Parent comment

Jason Kummerl

You need to check if prev_onload is null. window.onload = function() { if ( prev_onload) {prev_onload();} bar(); }

Replies

Jason Kummerl

Yes because if you have not defined window.onload before you grab is using 'var prev_onload = window.onload;' prev_onload will be null instead of a function.