I recently came cross a File Download Dialog problem. I was developing a web app, using the code below.
win=window.open('test.aspx','_blank', features);
Once click on the button, IE will open a new window for the test.aspx, which dynamically generate a PDF file, then a File Download Dialog poped up, but after choose either "Open", "Save" or "Cancel", IE leaves a blank window out there. I googled a while and firstly I found someone used "win.setTimeout", it didn't work well. Then I found a post mentioned the "http://support.microsoft.com/default.aspx?id=260519". So I changed the code to:
win=window.open('test.aspx','_self', features);
The reason is IE decide what to do after getting the content from test.aspx. If you set the Header properly,
Response.AddHeader("Content-Disposition", " attachment; filename=my.pdf")
IE will popup the File Download dialog directly, other than load the test.aspx to current page. The current page will stay unchanged.
No comments:
Post a Comment