I want to perform the following: when a page is unloaded (e.g. user opens a different page), it calls to the server and returns some information (e.g. how long the user had the page open for). To do that, I had something like this:
-
<iframe id="myframe" src="" style="display:none"/>
-
-
<script type="text/javascript">
-
this.onbeforeunload = function()
-
{
-
document.getElementById("myframe").src = "savestate.aspx?data=123";
-
// alert ('Hi');
-
}
-
</script>
-
The code above does not work since opening the page on the frame takes time and since it is too slow since the page is unloaded before that link is called. If I uncomment the alert statement, the script works. However I do not want the user to see the message box so I cannot do that. I have tried setTimeOut but it does not work since the page is being unloaded.
Anyone has any idea on how to solve this problem? Thanks.