I’m not sure what your plan with
alert is, but it won’t download a file for you. It just shows some text.
To the best of my knowledge, the behavior you’re looking for is mostly determined by the headers on the response to the request (and, of course, how the browser chooses to respond to them). What type of file is it? For example, if you have a ZIP file at a given URL and you request it, if it has
Content-Type: application/zip then most browsers will download it in the background and not leave the page, like you want. However if it’s, say, a text file and has a
Content-Type: text/plain header then usually the browser will try to display it since it can display that content.
So from some quick searching there might be some tricks that will work client side (Axure), but I don’t know which ones will or will not work. If you truly need a consistent experience, it might be worth investigating and properly setting header server-side.
It’s possible setting the type to
application/octet-stream server side might work as well.
I’m not terribly knowledgeable in this area, but this is to the best of my understanding. You honestly might be best served by just using Open in New Window if the above isn’t possible for you.