zoukankan      html  css  js  c++  java
  • 关于javascript以及jquery如何打开文件

    其实很简单,

    <input type="file" id="file"  mce_style="display:none">  
    

     这个就是html,call出文件对话框的。设置了隐藏。

    只需要用javascript,或是jquery,用click函数call出,id为file就可以了。

    <html>  
    <head>  
       <title> New Document </title>  
    </head>  
    <body>  
    <input type="file" id="file" style="display:none" mce_style="display:none">  
    <input type="button" value="click" onClick="ok()">  
    </body>  
    <script language="JavaScript"> 
    function ok(){  
    var s = document.getElementById("file");  
    s.click();  
    }  
    </script>  
    </html>  
    

      

    <html>  
    <head>  
       <title> New Document </title>  
    </head>  
    <body>  
       <input type="button" value="保存" onclick="document.execCommand('SaveAs')">  
    </body>  
    <script language="JavaScript"> 
          function SaveAs()  
       {  
        var fileSave = new ActiveXObject("MSComDlg.CommonDialog");  
        fileSave.Filter = "mp3";  
              fileSave.FilterIndex = 2;  
              // 必须设置MaxFileSize. 否则出错  
              fileSave.MaxFileSize = 128;  
              fileSave.ShowOpen();  
          }  
    </script>  
    </html>  
    

      

  • 相关阅读:
    jquery手写实现单页滚动导航
    小程序:商品分类,实现滑块视图
    微信小程序增加悬浮在线客服
    小程序 杂记
    自动售货机 扫描支付 原理
    HTTP的SSL 证书安装
    表达
    Linux 下svn恢复到某一版本
    倒车入库 技巧
    svn 杂记
  • 原文地址:https://www.cnblogs.com/JamyWong/p/7607964.html
Copyright © 2011-2022 走看看