【发布时间】:2015-02-19 20:06:07
【问题描述】:
我目前正在尝试仅在 Internet Explorer 8 中使用 Javascript 中的“SaveAs”execCommand 保存 XML 数据。我在打开窗口后使用 document.write(xml) 写入 xml 内容。IE8 中的文档对象使用 saveAs Exec 命令允许用户将 xml 文件保存在本地文件夹中。生成 XML 文件,但它没有将编码设置为我需要发送此 XML ANSI/UTF 的不同接口的首选类型-8 编码。我只能以 UCS2 little Endian 编码格式保存 XML。下面是我正在使用的代码。
var location = "D:\\export_to_MCT"+dateTime+".xml";
var xml = tmpSelectedConfigurationXML.transformNode(xslDoc);// XML Is generated here
alert(xml);
**var testlink = window.open ("about:blank","_blank","toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10000, top=10000, width=10, height=10, visible=none");
testlink.document.write(xml); //fileData has contents for the file
testlink.document.close();
testlink.document.execCommand('SaveAs', false, location);**
testlink.close();
我的目的是将xml保存为没有BOM格式的ANSI/UTF-8编码。我不能使用ActiveX对象的Scripting.FileSystemObject方法。请建议
【问题讨论】:
-
任何人都可以提出一些建议。这将有很大的帮助
标签: javascript encoding internet-explorer-8 window.open