This wont work and i dont know why, help?

all this is meant to do is display the “please dont leave” message when the person navigates away from the site (which is why the google link is present) but for some reason it wont work if anyone could help i would much appreciate it.
CODE:

<html>
<head></head>
<body>

function goodbye ()

{

alert (Please Dont Leave) ;

}

window.onunload goodbye ;

<a href “www.google.com”> Google </a>

</body>
</head>
</html>

You made several errors in your HTML / JavaScript. Here is a corrected version if someone leaves the page.


<html>
<head>
<title>test</title>
<script>
function goodbye() {
alert('Please Dont Leave');
}
</script>
</head>
<body onunload="javascript:goodbye();">
<a href="http://www.google.com">Google</a>
</body>
</head>
</html>

OR if someone leaves using only the link, will the popup show.


<html>
<head>
<title>test</title>
<script>
function goodbye() {
alert('Please Dont Leave');
}
</script>
</head>
<body>
<a href="http://www.google.com" onClick="javasscript:goodbye();">Google</a>
</body>
</head>
</html>