I need some help here:
I am writing code to redirect a user to a different page and execute some code, if the user closes the window while he is working on something:
<script type="text/javascript">
window.onbeforeunload = function() {
location.assign('http://www.somesite.com');
return "go?";
}
</script>
Now the code works fine if the user presses cancel. But if he presses Ok, the windows closes without a redirect.
I just need a working code that does one simple thing - redirect the user if the window is closed - can anyone suggest me the code for it
I know that most of you will say that I should not be doing this and I know that this is not the best practice. But if any one of you has written a successful piece of code, please share it here.