tags:

views:

505

answers:

1

Hi,

I've a servlet that is invoked via jquery ajax. The resulting XML is then transformed using XSL and displayed on screen. Now, the requirement is to either print or save this content to the local machine. The print portion is working fine but I'm stuck at the Save As part. How do I do this using jquery/javascript? I'm using IE8/XP.

I tried

document.execCommand('SaveAs');

on button click but it doesn't seem to work in IE8. It shows the alerts I put in till that point, but doesn't bring up the dialog box. What's going wrong here?

+1  A: 

If you can do this using server-side code instead of javascript then set the content-disposition header:

Content-Disposition: attachment
Simon Brown
Yes, but wouldn't that bring up the Save As dialog as soon as the servlet is invoked? I thought it would, haven't tried though. In my case, the content first needs to transform and display on the screen as HTML and then on a button click, should bring up the Save As dialog. Please see my comment above in response to Marc's question.
DS