zoukankan      html  css  js  c++  java
  • 贴一段用javascript打开和保存本地文件的源码

    <object   id="fileDialog"   width="0px"   height="0px"   classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB"   codebase="http://activex.microsoft.com/controls/vb5/comdlg32.cab">  
      </object>  
      <textarea   id=TxtBody   style="background-color:#EEEEEE;100%;height:100">无标题</textarea>  
      <br>  
      <input   type=button   value=加载   onclick="loadDoc()">  
      <input   type=button   value=保存   onclick="saveDoc()">  
      <script>  
      function   loadDoc()  
      {  
      fileDialog.CancelError=true;  
            try{  
            fileDialog.Filter="HTM   Files   (*.htm)|*.htm|Text   Files   (*.txt)|*.txt";  
              fileDialog.ShowOpen();  
            var   fso=new   ActiveXObject("Scripting.FileSystemObject");  
            var   reading=1;  
            var   f=fso.OpenTextFile(fileDialog.filename,reading);  
            //window.confirm(f);  
            var   r=f.ReadAll();  
            f.close();  
            TxtBody.value=r;  
            }catch(e){}  
      }  
      function   saveDoc()  
      {  
      fileDialog.CancelError=true;  
          try{  
          fileDialog.Filter="HTM   Files   (*.htm)|*.htm|Text   Files   (*.txt)|*.txt";  
          fileDialog.ShowSave();  
          var   fso=new   ActiveXObject("Scripting.FileSystemObject");  
          var   f=fso.CreateTextFile(fileDialog.filename,true);  
          f.write(TxtBody.value);  
          f.Close();  
          }  
          catch(e){}  
      }  
      </script>  
      </body>  
  • 相关阅读:
    053532
    053531
    053530
    053529
    053528
    RTSP和RTMP的区别是什么?
    RTSP、RTMP和HTTP协议的区别
    在C#中实现视频播放器
    wpf下基于opencv实现视频播放器
    C#实现视频播放器(Vlc.DotNet)
  • 原文地址:https://www.cnblogs.com/strinkbug/p/566033.html
Copyright © 2011-2022 走看看