Follow url using JavaScript

Is there a way to track the url in JavaScript without installing it document.location.href

?

I have a page that displays a list of objects, and each object can have a file download associated with it, which is accessed via a hyperlink. Clicking on the link initiates an AJAX request, which ultimately results in a generated temporary file that can be referenced by a unique and temporary URL.

The moment the AJAX call completes, it just sets document.location.href

to a temporary url and the file download starts. Of course, this has the side effect of changing the URL in the browser's address bar, so if the page is refreshed, the file is loaded again and the object list page itself refreshes. I guess I could set the url back to what it was before, but this is a bit of a hack.

By the way, I'm using the JavaScript prototype framework.

+1


source to share


3 answers


can you open a new window with a new url? or try setting the iframe url to a new url, both should present a file upload (the latter is the best option)



+3


source


You can use a hidden iframe - set the src of this file to load.



+2


source


If you're doing all of this just to trigger a file upload, this sounds like a good application to use a hidden iframe. Set the SRC for the Iframe instead, so you don't need to mess with the master page.

+2


source







All Articles