但是图片可以是svg的话
function saveAs(Url,filename){
var blob=new Blob([''], {type:'application/octet-stream'})
var url = webkitURL.createObjectURL(blob)
var a = document.createElementNS(xhtml,'a')
a.href = Url
a.download = filename
var e = document.createEvent('MouseEvents')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
webkitURL.revokeObjectURL(url)
2. saveAs(data,"new.svg")
<script language="javascript">function SaveAs(href,name)
{
var a = window.open(href)
a.document.execCommand('Saveas',true,name)
a.window.close()
return false
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>实验</title>
</head>
<body>
<a href="1.jpg" onClick="return SaveAs(this.href,'1.jpg')">下载</a>
</body>
</html>