I've got a problem with the onunload
event testing script
it must fire only on the window onunload
but it fires with load as well.. Why?
There is something wrong, and I don't know what it is..
Please help
Here is the html code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function hello(){alert("welcome to my page");}
</script>
<script type="application/javascript" src="script.js"></script>
</head>
<body onload="hello()" >
</body>
</html>
and here's the script code
window.onunload = goodbye();
function goodbye(){
alert("Thank you for visiting.come back soon!");
}
//window.addEventListener('unload',goodbye(),false);
I've tried the inline calling with body tag, the window.onunload
calling and the listener calling.
Nothing works correctly, and I get the "Thank you for visiting. come back soon!" message when the page first loads.