How to detect support for the HTML5 “download” attribute?

前端 未结 2 1776
后悔当初
后悔当初 2020-11-29 06:39

One of the new features implemented in HTML5 is the download attribute for anchor tags. The benefit of this attribute is that it gives users the means to downlo

2条回答
  •  鱼传尺愫
    2020-11-29 06:43

    Use the Modernizr approach: create the element, and check if the attribute is defined:

    var a = document.createElement('a');
    if (typeof a.download != "undefined") {
        alert('has support');
    }
    

提交回复
热议问题