读书人

html里如何弹出另存为对话框

发布时间: 2013-01-19 11:41:36 作者: rapoo

html里怎么弹出另存为对话框
我的html里有一个img,是这样写的


<span style="display:inline">
<!--chd=t:22,33,19,15,25 chl=22|33|19|15|25 Total Number++124-->
<img NAME="anImage" height="250" src="https://chart.googleapis.com/chart?" alt="html里如何弹出另存为对话框">
</span>

其中的img是利用google api画图的url。然后我想在页面上家一个button,点击的时候弹出另存为对话框,保存后是将这个img存到本地,html代码该怎么写呢?
[解决办法]
说错了,这个是从网上找的,你可以试试看

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> 通过js保存图片到本地 </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script>
function DownLoadReportIMG(imgPathURL) {

//如果隐藏IFRAME不存在,则添加
if (!document.getElementById("IframeReportImg"))
$('<iframe style="display:none;" id="IframeReportImg" name="IframeReportImg" onload="DoSaveAsIMG();" width="0" height="0" src="about:blank"></iframe>').appendTo("body");
if (document.all.IframeReportImg.src != imgPathURL) {
//加载图片
document.all.IframeReportImg.src = imgPathURL;
}
else {
//图片直接另存为
DoSaveAsIMG();
}
}
function DoSaveAsIMG() {
if (document.all.IframeReportImg.src != "about:blank")
document.frames("IframeReportImg").document.execCommand("SaveAs");
}
</script>

</head>

<body>
<input type="button" value="download image" onclick="DownLoadReportIMG('http://www.oursss.com/uploads/photo/1045_2590.jpg?rd=0.9961522558898981');">
</body>
</html>

来自:http://www.cnblogs.com/Renn/archive/2011/08/02/2125047.html

读书人网 >CSS

热点推荐