I heed to save image on click and for this purpose I use download attribute
<a href="http://mysite.ru/userfiles/certificate_2.png" class="download-certificate-link" data-title="certificate.png" download="certificate.png">Download</a>
and also I would like to add script for browsers which don't support HTML5 download attribute 
var a = document.createElement('a');
if (typeof a.download == "undefined") {
    $('body').on('click', '.download-certificate-link', function(){
        $(this).attr('href').download;
        return false;
    });
}
but this script doesn't work. What's wrong and how to fix it?
 
     
    