Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
index.js 1.58 KB
Copy Edit Raw Blame History
jing authored 2024-10-24 01:05 . add index.js.
//当打开html自动调用
window.onload = function() {
//调用随机函数
loadRandomImage();
}
//函数
function loadRandomImage() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
//始终进行
if (xhttp.status === 200) {
//将所有图片url放入imageUrls当中
var imageUrls = this.responseText.split("\n");
//实现随机访问
var randomIndex = Math.floor(Math.random() * imageUrls.length);
//实现额面跳转
window.location.href="https://i.imgtg.com/" + imageUrls[randomIndex] + ".jpg";
}
else{
console.log("图片文件状态异常,可联系foryouos@qq.com")
}
};
//打开文件
xhttp.open("GET", "photos_urls.txt", true);
xhttp.send();
}
}
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化