See if the following works for you:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', CallOnLoad, false);
function CallOnLoad()
{
alert("This function is called when DOM content is loaded.");
}
</script>
</body>
</html>
:)