-
Notifications
You must be signed in to change notification settings - Fork 0
/
p.html
113 lines (96 loc) · 3.11 KB
/
p.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#333333"> <!-- 暗色模式主题颜色 -->
<title>文本数据展示</title>
<style>
body {
margin: 0;
padding: 20px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #cccccc;
/* 文本颜色 */
background-color: #222222;
/* 暗色背景 */
transition: background-color 0.3s;
/* 平滑过渡背景色变化 */
}
.container {
max-width: 800px;
margin: auto;
background-color: #333333;
/* 容器背景色 */
padding: 20px;
border-radius: 8px;
/* 圆角边框 */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
/* 盒子阴影 */
}
h1 {
color: #ffffff;
/* 标题颜色 */
}
p {
line-height: 1.6;
/* 行高 */
}
/* 暗色模式媒体查询 */
@media (prefers-color-scheme: dark) {
body {
background-color: #222222;
color: #cccccc;
}
.container {
background-color: #333333;
}
h1 {
color: #ffffff;
}
p {
color: #cccccc;
}
#extend {
opacity: 0.6;
font-style: italic;
}
}
</style>
</head>
<body>
<div class="container">
<h1 id="title">标题 QueryParam: [t] or [title]</h1>
<p id="content">内容数据 QueryParam: [c] or [content]</p>
<p id="extend">扩展数据 QueryParam: [e] or [extend]</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
// 获取URL的查询参数
function getQueryParam(param) {
var queryParams = new URLSearchParams(window.location.search);
return queryParams.get(param);
}
// 根据查询参数获取数据
function displayData() {
var title = getQueryParam('t') ?? getQueryParam('title');
if (title) {
document.getElementById('title').textContent = title;
document.title = title;
}
var content = getQueryParam('c') ?? getQueryParam('content');
if (content) {
document.getElementById('content').textContent = content;
document.getElementById('extend').textContent = "";
}
var extend = getQueryParam('e') ?? getQueryParam('extend');
if (extend) {
document.getElementById('extend').textContent = extend;
}
}
// 调用函数以显示数据
displayData();
});
</script>
</body>
</html>