4

I have a xml content and I want to write it in a temporary xml file and later prompt user to save it.I have this...

var xml_content = document.getElementById('content_xml').value;
var downloadable=encodeURIComponent(xml_content);
document.location= 'data:Application/octet-stream,' +downloadable;

please help me with a pure javascript code, I mean without jquery.

Poles
  • 3,585
  • 9
  • 43
  • 91

1 Answers1

5

You could use localstorage to achieve something similar

localStorage.setItem("tempxml", xml_content);

Then, for retrieving it (even when the user closed and reopened the browser):

var xml_content = localStorage.getItem("tempxml");

localStorage is available in recent browsers, contents are saved on user's browser data (client side of course).

Hope this helps. Cheers

Edgar Villegas Alvarado
  • 18,204
  • 2
  • 42
  • 61