call php file from within javascript

Started by glenntamis, May 01, 2010, 03:13:12 PM

glenntamis

Hi..

Can someone please help me with this:

<script type="text/javascript">
window.onbeforeunload = function (evt) {
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
<a href="http://www.1stacademy.net/hello.php">
}
return;
}
</script>

I have inserted the code above into a html page so the javascript gets called when the user leaves my web page. what I want to be able to do is execute the file "hello.php" when someone leaves the page. Can anyone tell me what I would replace the line <a href="http://www.1stacademy.net/hello.php" with to do this?

Thanks
Derek

zubrag

replace with
window.location="http://www.example.com";