Skip to content

Instantly share code, notes, and snippets.

@petertenhoor
Created June 25, 2019 08:03
Show Gist options
  • Select an option

  • Save petertenhoor/c1baccb9936e43bf9a6c41b2f5b16be1 to your computer and use it in GitHub Desktop.

Select an option

Save petertenhoor/c1baccb9936e43bf9a6c41b2f5b16be1 to your computer and use it in GitHub Desktop.
Simple ES5 fallback for download attribute (IE11)
(function () {
'use strict';
//handle browsers that do not support download attribute
if (Modernizr.adownload === false) {
//get array of all links and area's with download attributes
var $downloadElements = Array.prototype.slice.call(document.querySelectorAll('a[download], area[download]'));
//remove download attributes
$downloadElements.forEach(function ($downloadElement) {
$downloadElement.removeAttribute('download');
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment