HTML
<div class="layui-upload-list">
<img class="layui-upload-img" src="plug-in/easyui/themes/icons/pdfIcon.png" style="width: 92px; height: 92px;" id="idTongdunUrlEleView" onclick="onDownloadImg('文字信息','http://url.pdf')">
</div>
点击下载
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a1e4b727d7584aa285cb5298566564e7.png)
js
function onDownloadImg(title, url){
layui.use('layer', function(){
if(url == ""){
parent.layer.msg("暂无文件可下载!");
return false;
}
var layer = layui.layer;
parent.layer.confirm('确定要下载'+title+"吗?", function (index) {
layer.close(index);
var $a = document.createElement('a');
$a.setAttribute("href", url);
$a.setAttribute("download", "");
var evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent( 'click', true, true, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
$a.dispatchEvent(evObj);
});
})
}