Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteCranes authored Nov 26, 2024
1 parent 519b9ae commit 0a9f1f8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
<meta charset="UTF-8">
<title>哈哈</title>
<script>
// 检查当前协议是否为HTTPS
// 检测是否为HTTPS
if (window.location.protocol === 'https:') {
// 构建HTTP URL并进行重定向
const httpUrl = window.location.href.replace('https:', 'http:');
window.location.href = httpUrl;
// 构建新的HTTP URL
var httpUrl = window.location.href.replace('https:', 'http:');

// 尝试使用多种方法重定向
try {
// 方法1: location.replace
window.location.replace(httpUrl);

// 方法2: 如果第一个方法失败
setTimeout(function() {
window.location.href = httpUrl;
}, 10);
} catch(e) {
console.error('重定向失败', e);
}
}
</script>
<style>
Expand Down

0 comments on commit 0a9f1f8

Please sign in to comment.