Created
June 25, 2019 08:03
-
-
Save petertenhoor/c1baccb9936e43bf9a6c41b2f5b16be1 to your computer and use it in GitHub Desktop.
Simple ES5 fallback for download attribute (IE11)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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