jQuery: $(document).ready() is much better than onload()
It is very important to load Javascript functions only after the HTML (Hypertext Markup Language) or more precisely the DOM (Document Object Model) is completely loaded.

For this purpose there is the function onload in HTML, which can be executed in the <body> — tag.
<html>
<head>
<script type="text/javascript">
function load()
{
alert(„The page was loaded");
}
</script>
</head>
<body onload="load()">
<h1>page content</h1>
</body>
</html>
W3C says that all leading web browsers fully support it. In practice, however, it has been found that when working with jQuery it is much better and more reliable to use $(document).ready(function().
<html>
<head>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert(„The page was loaded");
});
</script>
</head>
<body>
<h1>page content</h1>
</body>
</html>
Javascript function if body onload is not used.
window.onload = function(){
alert(„The page was loaded");
}