Search code examples
javascripthtmlinternet-explorerwxwidgets

Dynamic download link does not work in wxWebView under Windows


I have a web page loaded within a wxWebView on windows (running the Trident engine I presume) that includes the following button:

<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 code loaded by this page has the following:

$("#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;
});

When I test this page in Chrome, the JSON object generated by dcp_generator.save_config() will get downloaded to a file. When I run this within the embedded wxWebView (using Trident) and, presumably, under Internet Explorer, there is no apparent result that comes from clicking on the link.

The purpose of this link and code is to save the configuration structure to a local file. Is there any reason why this type of link does not work with Internet Explorer? Is there any way to work around this short of having the page bounce the content off the server?


Solution

  • The download HTML 5 attribute is not supported by Internet Explorer.

    As explained here CanIuse

    You have to change the download code to make it work with IE.