<input type=button value=保存     onclick="document.execCommand('SaveAs')">
<input type=button value=另存为   onclick="document.execCommand('Saveas',false,'c:\\test.htm')">

解决方案 »

  1.   

    sorry,我的意思,不是把当前页面保存
    而是把一个链接保存,本来是
    <a href="aaa.doc">下载</a>
    现在想实现一个按钮点击以后把aaa.doc另存为,就像右键点击链接选择“目标另存为”一样。
      

  2.   

    将aaa.doc 压缩成aaa.zip
    <a href="aaa.zip">下载</a>这样就可以自动下载了!
      

  3.   

    再把我的问题明确一下
    我的目的是为了记录下载的次数
    我的做法是当用户点击了右键选择“另存为”的时候,用onmoursedown去更新一次下载次数
    但是如果用户在另存为窗口选择了取消,这样记录就有问题了有没有好办法?
      

  4.   

    我使用jsp 自己写下载代码 在下载完成的时候就可以更新计数器了!@
      

  5.   

    比如(jsp部分代码):<a href="down.jsp?ID=文件.doc">下载</a> <%@ page import="java.io.*" %><%
      String fileName = request.getParameter("ID");
      fileName=new String(fileName.getBytes("ISO8859_1"),"GBK");
      response.setContentType("APPLICATION/OCTET-STREAM"); 
      response.addHeader("content-type", "application/x-msdownload;");
      response.setHeader("Content-disposition","attachment; filename=file" + fileName +".doc");//暂时不能处理中文文件名 a=response.encodeURL(fileName)
      //上面這一行就是讓瀏覽器知道要用下載的方式來儲存檔案,檔名設定為test.doc
      //如果要讓瀏覽器線上開啟檔案,那就把attachment改成inline就可以了  String path=application.getRealPath("")+"\\download\\"+fileName+".doc";
        
      java.io.File file = new java.io.File(path);
      java.io.FileInputStream fin = new java.io.FileInputStream(file);
      //以上這行設定一個FileInputStream,參數設定檔案的原始路徑加檔名即可
      OutputStream os=response.getOutputStream();
      //取得response的OutputStream,以便等一下直接輸出檔案
     byte[] b = new byte[1];
    int j = 0;
    while((j = fin.read(b)) > 0)
    {
    os.write(b);
    }
      os.close();
      if (fin != null)
         fin.close();注:在此处添加判断下载成功和更新计数器的功能就行了!
    %>
      

  6.   

    '显示下载排行 
    '呵呵~应该能知道下载次数吧
    sub sortdown()
    absPageNum = 1
    RecordPerPage = 10
    Set rsdown = Server.CreateObject("ADODB.Recordset")
    rsdown.CursorType = adOpenStatic
    rsdown.CacheSize = RecordPerPage
    sqldown="SELECT * FROM download where sortcount="&sortall&" order by downcount desc"
    rsdown.OPEN sqldown, Conn,1,1
    rsdown.PageSize = RecordPerPage
    If Not(rsdown.EOF) Then
    rsdown.AbsolutePage = absPageNum
    End If
    if rsdown.eof and rsdown.bof then
    response.write "document.write('无内容')"
    else
    For absRecordNum = 1 to rsdown.PageSize
    '长度判断
    longrdown=rsdown("name")
    if len(longrdown)>9 then
    longrdown=left(longrdown,9) & "..."
    end if
    if request("wz")="1" then
    response.write "document.write('<li><a href=http://www.80show.com/download/show.asp?id="&rsdown("id")&" title="""&rsdown("name")&" - "&rsdown("big")&"|"&rsdown("sort")&" "&rsdown("time")&" "&rsdown("count")&"/"&rsdown("downcount")&""" target=_blank>"&rsdown("name")&"</a> <font color=red>"&rsdown("count")&"/"&rsdown("downcount")&"</font>');"
    else
    response.write "document.write('<li>[<a href=http://www.80show.com/download/index.asp?type="&rsdown("sortcount")&">"&rsdown("sort")&"</a>] <a href=http://www.80show.com/down/show.asp?id="&rsdown("id")&" title="""&rsdown("name")&" - "&rsdown("big")&"|"&rsdown("sort")&" "&rsdown("time")&" "&rsdown("count")&"/"&rsdown("downcount")&""" target=_blank>"&longrdown&"</a> <font color=red>"&rsdown("count")&"/"&rsdown("downcount")&"</font>');"
    end if
    rsdown.movenext
    If rsdown.EOF Then  
    Exit For  
    End If  
    Next
    end if
    rsdown.close
    set rsdown=nothing
    end sub