Zubrag.com :: Forum

Programmers Lounge => PHP / MySql / Smarty Questions => Topic started by: glenntamis on May 01, 2010, 06:13:12 AM



Title: call php file from within javascript
Post by: glenntamis on May 01, 2010, 06:13:12 AM
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


Title: Re: call php file from within javascript
Post by: zubrag on May 04, 2010, 03:04:34 AM
replace with
window.location="http://www.example.com";