First of all, before the question I'll do the justification - because I realise this is a sensitive "no no" private area of the user's browsing experience. I only need/want to be able to capture the target url's from my own domain (well actually only a single one, against a string match).
The question:
On my site I use "window.onbeforeunload" to give a confirmation that the user wants to leave the site when they're doing something which will be interrupted by leaving the site.
The problem is that when a user requests a certain file to download, I use "window.location" to point to the PHP script which in-turn starts the file download.
Now, the user's browser never actually changes pages, but because I'm launching the download through "window.location" it's triggering the "window.onbeforeunload". Is there any way that I can detect that I'm requesting the download (like matching the script name in the target url?) and then not show the leaving confirmation?


Reply With Quote
Bookmarks