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,497
  • 8
  • 41
  • 89

1 Answers1

4

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
  • 17,924
  • 2
  • 41
  • 61