I am back to the basics, in order to better understand JavaScript. I have a testing website. Here is my code
<html>
<head>
test
</head>
<script type="text/javascript">
function saySomething(message)
{
alert(message);
}
saySomething('Hello world!');
function addLoadListener(fn){
window.addEventListener('load', fn, false);
alert("the previous alert came from onload");
}
addLoadListener(saySomething);
</script>
<body>
<div>blah blah blah</div>
</body>
</html>
So, there is this function, saySomething that alerts Hello World!. I add it to addLoadListener so it can be called during page loading. And works fine till this part. But after that, gets called again as the code runs and alerts [object Event] instead of Hello World!. Why? What am I missing?
Thanks
Hello World!after the page load. Also it would be nice if you provide an explanation of why this is happening. ThanksonLoadtoNo wrap - in <head>