IE write XML file in two ways (Fso/saveas) _ Basic knowledge

Source: Internet
Author: User
Browsers such as Firefox do not support writing local files for security reasons.
IE can write XML files in the following ways

Mode one: FSO
Copy Code code as follows:

Loadxml () read XML under IE
var xmldom = Loadxml ("config.xml");
var contenttext = "";
if (typeof xmldom.xml!= ' undefined ') {
ContentText = Xmldom.xml;
var fso = new ActiveXObject ("Scripting.FileSystemObject");
var file = fso. CreateTextFile ("D:\\test\\test.xml", true);
File. Write (ContentText);
File. Close ();

Create a text file
CreateTextFile (Filename,overwrite,unicode)
FileName: filename
Overwrite: If the file exists, overwrite it, and the default is False
Unicode: Whether the contents of the file are stored as Unicode text;

Mode two: SaveAs
Hide iframe in page embedding,
Copy Code code as follows:

<iframe name= "Export" src= "About:blank" style= "Display:none"; ></iframe>

Writes the XML content to the IFRAME and saves as a file.
Copy Code code as follows:

var frame = window.frames["Export"];
Frame.document.open ();
Frame.document.write (ContentText);
Frame.document.execCommand ("SaveAs", True, "test.xml");
Frame.document.close ();

In addition, IE Xmldom has a Save method
Hint does not have permission to browse IE Security policy settings, also did not find the right to modify the place
This method should not be done.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.