刷新后是否可以重定向回登录页面?
我正在使用此密码保护代码。
https://github.com/matteobrusa/Password-protection-for-static-pages
因为我部署在netlify中。它不支持.htaccess
我已经尝试过此代码。
window.onload = function () {
window.location = "../index.html";
}
但是在页面加载时,它会自动重定向到登录页面。
*我是新来的
谢谢,:)
代替window.location
使用window.location.href
。
我找到了解决方案。但不适用于歌剧
编辑:适用于歌剧
window.onbeforeunload = function() {
window.setTimeout(function () {
window.location = 'index.html';
}, -1);
window.onbeforeunload = null; // necessary to prevent infinite loop, that kills your browser
}
我从]找到了这个解决方案>