Repository navigation
Expand file tree
/
Copy pathword.html
More file actions
60 lines (53 loc) · 1.73 KB
/
Copy pathword.html
File metadata and controls
60 lines (53 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>下载 Word 文档</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
font-family: sans-serif;
background-color: #f0f0f0;
}
.download-button {
padding: 15px 30px;
font-size: 18px;
cursor: pointer;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
text-decoration: none;
transition: background-color 0.3s ease;
}
.download-button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<button class="download-button" onclick="downloadWord()">下载 Word</button>
<script>
function downloadWord() {
const content = ` 替换为自己的内容或主题
这是一个示例文档,用于演示纯 HTML 和 JavaScript 实现的下载功能。
您可以根据需要修改此文件的内容和排版。
感谢您的使用!`;
const blob = new Blob([content], { type: 'text/plain;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'example.docx';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
</script>
</body>
</html>