Crow:实现点击下载功能

Crow:设置网站的index.html-CSDN博客

讲述了如何完成一个最简单的网页的路由

很多网页提供了下载功能,怎么实现呢,其实也很简单。

假设网页的目录结构如图

$ tree static
static
├── img
│   └── goodday.jpg
└── index.html

//index.html
<html>
<body>

<h1>Hello world</h1>
<img src="/static/img/goodday.jpg" alt="good day" style="width: 500px;" onclick="downloadimg('goodday1.jpg')">

<script>
    function downloadFile (data, fileName)
    {
        var blob = new Blob([data]);
        var downloadElement = document.createElement('a');
        var href = window.URL.createObjectURL(blob);
        downloadElement.href = href;
    

相关推荐

  1. Crow实现下载功能

    2024-01-21 16:34:02       41 阅读
  2. js实现音频实现播放功能

    2024-01-21 16:34:02       40 阅读
  3. uniapp实现选项跳转到应用商店进行下载

    2024-01-21 16:34:02       24 阅读
  4. uniapp实现图片预览放大,长按下载图片

    2024-01-21 16:34:02       19 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-21 16:34:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-21 16:34:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-21 16:34:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-21 16:34:02       20 阅读

热门阅读

  1. HBase鉴权设计以及Kerberos鉴权方法

    2024-01-21 16:34:02       37 阅读
  2. Spring框架常用注解

    2024-01-21 16:34:02       32 阅读
  3. 【Spring Boot 3】【Redis】消息发布及订阅

    2024-01-21 16:34:02       35 阅读
  4. Vue待办事项(组件,模块化)

    2024-01-21 16:34:02       29 阅读
  5. python生成列表坑

    2024-01-21 16:34:02       39 阅读
  6. react mac 安装

    2024-01-21 16:34:02       36 阅读
  7. chatgpt和文心一言哪个更好用?更智能?

    2024-01-21 16:34:02       39 阅读
  8. 三、05-ansible安装

    2024-01-21 16:34:02       41 阅读