js打开word文档,而不是下载

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script> function openmydoc(path) {  var doc = new ActiveXObject("Word.Application"); doc.visible = true; doc.Documents.Open(path); } </script>
</head>
<body>

<a onclick="openmydoc('D:\\word\\go.doc');" type="activxobject(word.application)">
    点击我!!!打开word文档,而不是下载
</a>
</body>
</html>

第二种方法

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script language="Javascript"> function doword() {  var WordApp = new ActiveXObject("Word.Application"); WordApp.Application.Visible = true; var Doc = WordApp.Documents.Add("D:\\word\\go.doc",true); //下面是以只读方式打开 var openDocObj = new ActiveXObject("SharePoint.OpenDocuments.1"); openDocObj.EditDocument("http://localhost/cmt/go.doc"); } </script>
</head>
<body>
<button onclick="doword()">打开Word模板</button>
</body>
</html>
    原文作者:longzhoufeng
    原文地址: https://blog.csdn.net/longzhoufeng/article/details/78783123
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞