JS脚本实现刷新页面,随机加载背景图片
1.JS脚本实现刷新页面,随机加载背景图片
新建switch.js
,内容如下:
var imgs = [
"https://mlabs.gitee.io/pics/webp/tiankong002-mid.webp",
"https://mlabs.gitee.io/pics/webp/wallhaven-gp1q87.webp",
"https://mlabs.gitee.io/pics/webp/shanshui007small.webp",
"https://mlabs.gitee.io/pics/webp/shenlin001-small.webp",
"https://mlabs.gitee.io/pics/webp/shanshui005-small.webp",
"https://mlabs.gitee.io/pics/webp/shanshui005-mid.webp",
"https://mlabs.gitee.io/pics/webp/shanshui004-small.webp",
"https://mlabs.gitee.io/pics/webp/shanshui003-samll.webp",
"https://mlabs.gitee.io/pics/webp/jianzhou001-small.webp",
"https://mlabs.gitee.io/pics/webp/wallhaven-exvvqk.webp",
"https://mlabs.gitee.io/pics/webp/tianyuan001-small.webp",
"https://mlabs.gitee.io/pics/webp/yuzhou001-small.webp",
];
var index=Math.floor(Math.random()*imgs.length);;
var img = imgs[index];
document.write("<BODY BACKGROUND="+img+" no-repeat>");
新建switch.html
,内容如下:
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
<title>Switch</title>
<script src="./switch.js"></script>
<style>
body {
background-color: #efefef;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center 0;
background-size: cover;
}
</style>
</head>
<body>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能