<input type=button value=另存为   onclick="document.execCommand('Saveas',false,'c:\\test.xml')" />

解决方案 »

  1.   

    多谢楼上的,但是
    这个是把网页另存为,我需要的是我在客户端获得一个xml字符串,然后将其另存为一个xml文件!!
      

  2.   

    你可以先 var win = window.open() 出一个新页面, 然后再 win.document.execCommand() 在保存完成之后再用 win.close() 关闭掉这个临时窗口即可.
      

  3.   

    多谢啊,那我怎么把这个xml字符串window.open() 出一个新页面啊,我要存储的只是包括这个xml字符串的内容!
      

  4.   

    唉:
    var win = window.open("","");
    win.document.write(xmlString);
    win.document.close();
    win.document.execCommand('Saveas',false,'c:\\test.xml');
    win.close();
      

  5.   

    保存成xml文件可以,怎么样才能保存成csv文件?