Home  >  Article  >  Web Front-end  >  Save a File Using a File Save Dialog Box_javascript技巧

Save a File Using a File Save Dialog Box_javascript技巧

WBOY
WBOYOriginal
2016-05-16 19:12:121310browse

Demonstration script that allows you to enter a file name in a File Save dialog box, and then saves a sample text file (consisting entirely of the current date) under that file name. 

Supported Platforms

Windows Server 2003
 No

Windows XP
 Yes

Windows 2000
 No

Windows NT 4.0
 No

Windows 98
 No


Script Code

复制代码 代码如下:

Set objDialog = CreateObject("SAFRCFileDlg.FileSave") 

objDialog.FileName = "C:ScriptsScript1.vbs" 
objDialog.FileType = "VBScript Script" 
intReturn = objDialog.OpenFileSaveDlg 

If intReturn Then 
    Set objFSO = CreateObject("Scripting.FileSystemObject") 
    Set objFile = objFSO.CreateTextFile(objDialog.FileName) 
    objFile.WriteLine Date 
    objFile.Close 
Else 
    Wscript.Quit 
End If 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn