极度求救 请问jscript 能不能实现下载 不能,客户端脚本不可以。如果要下载本地文件,需通过组件或fso. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jscript +xmlhttp +domdom中以2进制读取文件不过会有安全问题 需要将IE安全设置低点 jsp的<%@ page contentType="text/html; charset=GBK" %><%@ page errorPage="error.jsp"%><%@ page import="jb.database.*"%><%@ page import="jb.database.exception.*" %><%@ page import="jb.function.*"%><%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 +".zip");//暂时不能处理中文文件名 a=response.encodeURL(fileName) //上面這一行就是讓瀏覽器知道要用下載的方式來儲存檔案,檔名設定為test.doc //如果要讓瀏覽器線上開啟檔案,那就把attachment改成inline就可以了 String path=application.getRealPath("/")+"\\download\\"+fileName+".zip" 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();%> 我估计你理解错了,jscript是微软的服务端ASP脚本,不是NETSCAPE的JAVASCRIPT客户端脚本jscript可以,js不可以,除非用组件并降低安全级别 用Response.Redirect(下载的文件名)吧,我以前帮人家做简单的网站都用这个的,一句话搞定 如何能过JS提交表单 Javascript看看这个统计 关于onclick事件 怎样用javascript实现图形样式的网站访问量计数器 javascript和flash通讯 showModelDialog 如何用js获取table中光标的位置? 页面刷新的问题 高手帮一下忙! javascript读写文件可否控制?给分 这样的功能要求是否能实现 可不可使用javascript 或 Vbscript 发送邮件
dom中以2进制读取文件不过会有安全问题 需要将IE安全设置低点
<%@ page contentType="text/html; charset=GBK" %><%@ page errorPage="error.jsp"%><%@ page import="jb.database.*"%><%@ page import="jb.database.exception.*" %><%@ page import="jb.function.*"%><%
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 +".zip");//暂时不能处理中文文件名 a=response.encodeURL(fileName)
//上面這一行就是讓瀏覽器知道要用下載的方式來儲存檔案,檔名設定為test.doc
//如果要讓瀏覽器線上開啟檔案,那就把attachment改成inline就可以了
String path=application.getRealPath("/")+"\\download\\"+fileName+".zip"
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();
%>
jscript可以,js不可以,除非用组件并降低安全级别