当前位置: 代码迷 >> JavaScript >> 简单链接有关问题
  详细解决方案

简单链接有关问题

热度:204   发布时间:2012-02-19 19:43:39.0
简单链接问题
<a   href= '../Manage/LoadFile/Pages/Mg_E_19.jpg '> <img   src= "../images/cofolder.gif "   border= "0 "   /> </a>

我想通过这个链接下在一幅图片,就是想通过保存对话框,将其保存到本地,可是实际是新开了一个页面,请问这个连接怎么写

------解决方案--------------------
document.execCommand( "saveas ")

是保存页面的


要保存图片,用后台把

------解决方案--------------------
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en " "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd ">
<html>
<head>
<meta http-equiv= "content-language " content= "zh-cn ">
<meta name= "author " content= "forfor ">
<title> Test Document </title>
<script type= "text/javascript ">
<!--
function runSave(){
if (saveImg.location != "about:blank ")window.saveImg.document.execCommand( "SaveAs ");
}
function saveImgAs(url){
if(window.saveImg && url)window.saveImg.location=url;
}
//-->
</script>
</head>
<body>
<img src= "http://www.52hai.com/2005/smile/07.gif ">
<a href= "# " onclick= "saveImgAs( 'http://www.52hai.com/2005/smile/07.gif ') "> 1 </a> <br>
<img src= "http://www.52hai.com/2005/smile/06.gif ">
<a href= "# " onclick= "saveImgAs( 'http://www.52hai.com/2005/smile/06.gif ') "> 1 </a>
<iframe src= "about:blank " name= "saveImg " onload= "runSave() " style= "display:none; "> </iframe>
</body>
</html>
  相关解决方案