View Full Version : Download Dialog Box

03-11-2009, 09:30 AM
Hello all,

I have a web page with a link to download an XML file. When the user clicks on the link, the browser displays open/save dialog box. If the user selects 'open' I would like the file to be opened in a new window, overriding the default behavior of the browser. I am using JSP/Struts and I was wondering if there was any way to do this with JavaScript.

Thanks a lot for the help!

Philip M
03-11-2009, 09:35 AM
JavaScript is purely a client-side language, and unless used with an Ajax call has no capability to read from or write to a file (except a cookie), access a database or the client's operating system, or override the default behaviour of the browser. And for security reasons JavaScript cannot access anything beyond the domain of the current page. This is known as the "same origin policy" and prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin.