请问,如何在客户端将服务器端的WORD文件下载到本地 <a href=要下载的文档路径 target=_blank>名称</a> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我要通过按钮来触发这个事件。。原先有段代码是在本地新键一个空白WORD文档,再打开。现在我想实现的是从服务器下载WORD文档,然后打开它。原来的代码:document.all.item("ifedit").value="1";document.all.item("zhtshow").value="clearVersion";var fsoFolder = new ActiveXObject("Scripting.FileSystemObject");//生成文件路径if (!fsoFolder.FolderExists("c:\\Program Files\\temp")){ fsoFolder.CreateFolder("c:\\Program Files\\temp");} var tempfile = "c:\\Program Files\\temp\\"+document.forms[0].WebDocId.value+".html";var itemname = "Body";var username = document.forms[0].UserName.value; editfile (tempfile, itemname, username) <%@ page contentType="text/html; charset=gb2312"%><%@ include file="/DataIni/DataOpen.jsp"%><%@ include file="/ScriptLib/Init.jsp"%><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title></title><link rel="stylesheet" type="text/css" href="/StyleLib/Default_Style_Sheet.css"></head><body><%//@ include file="/TemplateLib/Wsh.jsp"%><%@ include file="/TemplateLib/Head.jsp"%><center><br><table border="0" cellpadding="0" cellspacing="0" width="80%"> <tr> <td width="100%" valign="top">测试XMLHTTP</td> </tr></table><br><!--http://10.70.38.10:9002/System/Dot/Show.jsp?Id=1为输出的文件流也可以是文件路径--><table border="0" cellpadding="0" cellspacing="0" width="80%"> <tr> <td width="100%" valign="top"><input type="text" value="http://10.70.38.10:9002/System/Dot/Show.jsp?Id=1" id="URLID"><input type="text" value="C:\\DownURL.doc" id="LocalURLID"><input type="button" value="下载" onclick="DownURL(URLID.value,LocalURLID.value);"> </td> </tr></table><br><div id=App style="border:1 solid #000000;background-color:#FFFFFF;height:200px;overflow:auto;width:80%;z-index:2" contentEditable></div><script>function OpenFile(strFileName){ try { var WordApp=new ActiveXObject("Word.Application"); WordApp.Application.Visible=false; var Doc=WordApp.Documents.Open(strFileName); Doc.Activate(); Doc.Parent.Options.InsertedTextColor=4; Doc.Parent.Options.InsertedTextMark=2; Doc.Parent.Options.DeletedTextColor=4; Doc.Parent.Options.DeletedTextMark=1; Doc.TrackRevisions=true; Doc.PrintRevisions=true; Doc.ShowRevisions=true; Doc.Application.UserName=""; var Range=Doc.Range(); Range.Select(); var Selection=WordApp.Selection; Selection.Copy(); App.focus(); document.execCommand("Paste"); App.focus(); WordApp.DisplayAlerts=false; Doc.Close(); WordApp.DisplayAlerts=true; WordApp.Quit(); } catch(e) { window.confirm(e); }}function DownURL(strRemoteURL,strLocalURL){ try { var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP"); xmlHTTP.open("Get",strRemoteURL,false); xmlHTTP.send(); var adodbStream=new ActiveXObject("ADODB.Stream"); adodbStream.Type=1;//1=adTypeBinary adodbStream.Open(); adodbStream.write(xmlHTTP.responseBody); adodbStream.SaveToFile(strLocalURL,2); adodbStream.Close(); adodbStream=null; xmlHTTP=null; OpenFile(strLocalURL); } catch(e) { window.confirm("下载URL出错!"); } //window.confirm("下载完成.");}</script><br><table border="0" cellpadding="0" cellspacing="0" width="80%"> <tr> <td width="100%" valign="top">测试XMLHTTP</td> </tr></table></br></center><%@ include file="/TemplateLib/Tail.jsp"%><%@ include file="/DataIni/DataClose.jsp"%></body></html> 哪位大大能帮助我研究一下这个sigma图形库的用法?最好能写个小的实例,我实在是不能看明白了,求助!! Ext的Element的createChild方法在IE和FF的显示问题 js功能时灵时不灵 如何设置禁止在新窗口和新选项卡打开页面? 显示在别人的网页上 以这种样式来做 一个简单解码的问题。 看看这个在线编辑器? 没有name,如何控制一个object 父窗口怎样对弹出的子窗口提交信息? 求有效数字算法!!! 动态内容不能访问
原先有段代码是在本地新键一个空白WORD文档,再打开。现在我想实现的是从服务器下载WORD文档,然后打开它。
原来的代码:document.all.item("ifedit").value="1";
document.all.item("zhtshow").value="clearVersion";
var fsoFolder = new ActiveXObject("Scripting.FileSystemObject");
//生成文件路径if (!fsoFolder.FolderExists("c:\\Program Files\\temp"))
{
fsoFolder.CreateFolder("c:\\Program Files\\temp");
} var tempfile = "c:\\Program Files\\temp\\"+document.forms[0].WebDocId.value+".html";var itemname = "Body";
var username = document.forms[0].UserName.value;
editfile (tempfile, itemname, username)
<%@ include file="/DataIni/DataOpen.jsp"%>
<%@ include file="/ScriptLib/Init.jsp"%>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="/StyleLib/Default_Style_Sheet.css">
</head>
<body>
<%//@ include file="/TemplateLib/Wsh.jsp"%>
<%@ include file="/TemplateLib/Head.jsp"%>
<center>
<br>
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="100%" valign="top">测试XMLHTTP</td>
</tr>
</table>
<br>
<!--http://10.70.38.10:9002/System/Dot/Show.jsp?Id=1为输出的文件流也可以是文件路径-->
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="100%" valign="top">
<input type="text" value="http://10.70.38.10:9002/System/Dot/Show.jsp?Id=1" id="URLID">
<input type="text" value="C:\\DownURL.doc" id="LocalURLID">
<input type="button" value="下载" onclick="DownURL(URLID.value,LocalURLID.value);">
</td>
</tr>
</table>
<br>
<div id=App style="border:1 solid #000000;background-color:#FFFFFF;height:200px;overflow:auto;width:80%;z-index:2" contentEditable></div>
<script>
function OpenFile(strFileName)
{
try
{
var WordApp=new ActiveXObject("Word.Application");
WordApp.Application.Visible=false;
var Doc=WordApp.Documents.Open(strFileName);
Doc.Activate();
Doc.Parent.Options.InsertedTextColor=4;
Doc.Parent.Options.InsertedTextMark=2;
Doc.Parent.Options.DeletedTextColor=4;
Doc.Parent.Options.DeletedTextMark=1;
Doc.TrackRevisions=true;
Doc.PrintRevisions=true;
Doc.ShowRevisions=true;
Doc.Application.UserName="";
var Range=Doc.Range();
Range.Select();
var Selection=WordApp.Selection;
Selection.Copy();
App.focus();
document.execCommand("Paste");
App.focus();
WordApp.DisplayAlerts=false;
Doc.Close();
WordApp.DisplayAlerts=true;
WordApp.Quit();
}
catch(e)
{
window.confirm(e);
}
}
function DownURL(strRemoteURL,strLocalURL)
{
try
{
var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("Get",strRemoteURL,false);
xmlHTTP.send();
var adodbStream=new ActiveXObject("ADODB.Stream");
adodbStream.Type=1;//1=adTypeBinary
adodbStream.Open();
adodbStream.write(xmlHTTP.responseBody);
adodbStream.SaveToFile(strLocalURL,2);
adodbStream.Close();
adodbStream=null;
xmlHTTP=null;
OpenFile(strLocalURL);
}
catch(e)
{
window.confirm("下载URL出错!");
}
//window.confirm("下载完成.");
}
</script>
<br>
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="100%" valign="top">测试XMLHTTP</td>
</tr>
</table>
</br>
</center>
<%@ include file="/TemplateLib/Tail.jsp"%>
<%@ include file="/DataIni/DataClose.jsp"%>
</body></html>