-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
61 lines (57 loc) · 2.03 KB
/
index.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
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>晖哥的页面 Hooay Chen's page</title>
<link rel="stylesheet" href="style/style.css">
<!-- <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.0.min.js"></script>-->
</head>
<body>
<noscript><h1>你的浏览器禁用了脚本,有些功能可能不能运行</h1></noscript>
<h1 class="auto">欢迎来到晖哥的个人页面</h1>
<h2>以内容下仅用于测试网页样式 TEST:</h2>
<main>
<p>晖哥是一个非常帅的人<br>
性别是<strong title="自认同性别武装直升机">男性</strong><br>
现在 <span id="age">14</span> 岁了
</p>
<p>项目:</p><br>
<input type="button" value="闰土与猹" onclick="jump('./rtyc', 'black')">
<input type="button" value="悬浮诗生成器" onclick="jump('./hpc')">
</main>
</body>
<script>
// 出生日期
const birthDate = new Date('2010-02-11');
const agespan = document.getElementById('age')
function updateAge() {
let now = new Date();
let ageMs = now - birthDate;
let ageSec = ageMs / 1000; // 将毫秒转换为秒
let age = ageSec / (60 * 60 * 24 * 365); // 将秒转换为年
// 将年龄格式化为精确到小数点后12位的字符串
let ageFormatted = age.toFixed(12);
// 更新页面上的元素
agespan.textContent = ageFormatted;
}
// 更新年龄显示
setInterval(updateAge, 50);
function whenVisibilityChange(){
if (document.visibilityState === 'hidden') {
document.title = '再见';
} else {
document.title = '欢迎回来';
document.body.className = "";
setTimeout(()=>{document.title = "晖哥的页面 Hooay Chen's page"}, 1000);
// setTimeout(()=>{document.removeEventListener('visibilitychange', whenVisibilityChange);}, 1500);
}
}
document.addEventListener('visibilitychange', whenVisibilityChange);
function jump(url, color){
color = color || "white";
document.body.className = "leave-to-"+color;
setTimeout(()=>{window.open(url)}, 700);
}
</script>
</html>