【问题标题】:Dynamic download link does not work in wxWebView under WindowsWindows下wxWebView中动态下载链接不起作用
【发布时间】:2016-06-24 23:16:29
【问题描述】:

我在 windows 上的 wxWebView 中加载了一个网页(我认为是运行 Trident 引擎),其中包括以下按钮:

<a href="#" 
   class="btn btn-info" 
   id="export_button" 
   download="settings.json">
  <span class="glyphicon glyphicon-floppy-save" aria-hidden="true"> 
  </span> Export</a> 

该页面加载的Javascript代码如下:

$("#export_button").click(function() {
  var config = JSON.stringify(dcp_generator.save_config());
  var export_button = $("#export_button");
  export_button.attr("href", "data:application/json," + encodeURI(config));
  return true;
});

当我在 Chrome 中测试这个页面时,由 dcp_generator.save_config() 生成的 JSON 对象将被下载到一个文件中。当我在嵌入式 wxWebView(使用 Trident)中运行它时,大概是在 Internet Explorer 下,点击链接没有明显的结果。

此链接和代码的目的是将配置结构保存到本地文件。为什么这种类型的链接不适用于 Internet Explorer?有什么办法可以解决这个问题,让页面从服务器反弹内容?

【问题讨论】:

    标签: javascript html internet-explorer wxwidgets


    【解决方案1】:

    Internet Explorer 不支持下载 HTML 5 属性。

    正如这里所解释的CanIuse

    您必须更改下载代码才能使用 IE。

    【讨论】:

    • 有什么方法可以保存本地内容而不涉及发送数据到服务器?
    • 当您说:保存本地内容时,您是什么意思? dcp_generator.save_config() 将为您生成 url,它指向驻留在服务器上的资源。所以你必须提出请求以获取文件......总是。
    • dcp_generator.save_config() 生成一个 Javascript 对象,该对象仅驻留在浏览器内存中,与服务器无关。
    猜你喜欢
    • 2014-09-10
    • 2015-02-09
    • 2013-12-16
    • 1970-01-01
    • 1970-01-01
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    相关资源
    最近更新 更多