Following code helps you to define any JS function to be called on page load. The tricky part of the code is that it waits until page is completely loaded.


<script>
function init() {
alert('Loaded');
}

var previousOnload = window.onload;
window.onload = function() {
if (previousOnload) {
alert('...loading ...');
previousOnload();
}

init();
}
</script>