1、打开word,会弹出一个对话框,询问打开、保存、取消
window.open("http://localhost/test/test.doc");
2、直接打开word文档
var word = new ActiveXObject("Word.Application");
word.Visible = true;
word.Documents.Open("http://localhost/test/test.doc");
3、不知道与2有什么区别
var openDocObj;
openDocObj = new ActiveXObject("SharePoint.OpenDocuments.2");
openDocObj.editDocument("http://localhost/test/test.doc");
下面是引用过来的,新增一个模板文档
<html>
<head>
<title>打开word文档</title>
<meta http-equir="content-type"
content="text/html";charset="gb2312">
<script language="Javascript">
function doword(doc) //doc为你的当前路径下的文件名
{
var url=unescape(window.location.href).replace( "file:///","");
url =url.substring(0,url.lastIndexOf("/")+1).replace("/","//");
url=url+doc;
var WordApp=new ActiveXObject("Word.Application");
WordApp.Application.Visible=true;
var Doc=WordApp.Documents.Add(url,true);
}
</script>
</head>
<body>
<button onClick="doword('test2.doc')">打开Word文档</button>
</body>
</html>