zoukankan      html  css  js  c++  java
  • 前端下载pdf等文件

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="UTF-8">
      <meta name="viewport"
            content="width=device-width, initial-scale=1.0">
      <title>Document</title>
    </head>
    <body>
      <button onclick="downloadFile()">Download</button>
      <script>
        function downloadFile() {
          var request = new XMLHttpRequest();
          request.responseType = "blob";
        // 传入文件链接 request.open(
    "GET", "http://124.128.28.25/20200524140900315079.pdf"); request.onload = function () { var url = window.URL.createObjectURL(this.response); var a = document.createElement("a"); document.body.appendChild(a); a.href = url; a.download = "your_download.pdf" a.click(); } request.send(); } </script> </body> </html>
  • 相关阅读:
    品优购注册页
    品优购详情页---产品细节模块product_detail
    品优购详情页---产品详细信息区域 iteminfo_wrap
    poj 3684
    POJ 2785
    POJ 3185
    POJ 3279
    POJ 3276
    POJ 2566
    POJ 2100
  • 原文地址:https://www.cnblogs.com/javascripter/p/13447731.html
Copyright © 2011-2022 走看看