I am generating a XMl document via JavaScript and need to prompt the user to save it to their local machine.
This is the code I have at the moment:
var xmlWindow = window.open("", "");
xmlWindow.document.write("<node>data</node>");
This writes the xml to a new window which the user can then hit file->save to download.
- Is there any more elegent way of doing this?
- Is there any way to set the mimeType of the new window so the xml displays properly?
- is there any way to specify the title so when the user hits save, the file name is set correctly?
note: needs to be compatible with most brosers (IE6, IE7, FF, Chrome).