UNPKG

1.13 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="UTF-8">
5 <title>Title</title>
6</head>
7<body>
8 <button onclick="printWord()">测试打印</button>
9 <button onclick="printTrueWord()">测试真实打印</button>
10</body>
11<script type="text/javascript">
12
13
14
15 function printWord()
16 {
17 var obj="http://117.39.29.95:8221/paoyici-city-uat-data/oss_portal/001/uploads/2018/300246d1-7af0-4d80-a15a-9e5d50f271b8/test.docx";
18 var wordApp = null;
19 try{
20 wordApp = new ActiveXObject('Word.Application'); }catch(e)
21 {
22 alert(e+', 原因分析: 浏览器安全级别较高导致不能创建Word对象或者客户端没有安装Word软件');
23 return;
24 }
25 //var Doc=wordApp.Documents.Open('http://'+window.location.host+obj.value);
26 var Doc=wordApp.Documents.Open(obj);
27 wordApp.Application.Visible = false;
28 wordApp.visible = false;
29 wordApp.ActiveDocument.printout();
30 wordApp.ActiveDocument.close();
31 wordApp.Quit();
32 wordApp=null;
33 }
34
35</script>
36</html>
\No newline at end of file