检测 chrome 是否正在加载缓存页面?
Detect if chrome is loading a cached page?
这是其中之一,"I need a workaround so as not to have to endure 1000 years of bickering from users, once the project launches" 输入问题:
我遇到这样一种情况,每当有人在上次关闭浏览器时未关闭选项卡而启动 Chrome 时,我都需要重新加载我的网站。我们正在现代、MEAN 堆栈环境中重建一个古老的网站,我只是 知道 当它启动时我会收到投诉。
换句话说(危险:伪代码)-
if client closed chrome with site open
reauthenticate user
redirect to home page
我可以通过 express route 和 passport auth 完成最后两位,但是我如何检测客户端是否正在从他们的端加载缓存页面?
Is it possible to simply store some sort of js variable that is only
set true after an actual login, or does Chrome keep that stored on
close as well?
一个简单的例子来配合我的评论:
<html>
<head>
<script>
function DoMagic() {
document.getElementById( "magic" ).innerHTML = "<h1>Hello World!</h1>";
}
</script>
</head>
<body>
<div id="magic">Waiting for magic</div>
<br>
<input type="button" value="Do Magic" onclick="DoMagic();" />
</body>
</html>
- 在 Chrome 中打开此 div 显示 "Waiting for magic"。
- 单击 "Do Magic" div 读取 "Hello World"。
- 单击 X(不是页面,浏览器)关闭 Chrome。
- 打开 Chrome。页面加载。 Div 读取 "Waiting for magic."
状态不会在浏览器关闭之间保留——即使缓存是。我想你可以实现类似的东西来确保他们必须在浏览器关闭之间登录。应该也适用于所有浏览器。
这是其中之一,"I need a workaround so as not to have to endure 1000 years of bickering from users, once the project launches" 输入问题:
我遇到这样一种情况,每当有人在上次关闭浏览器时未关闭选项卡而启动 Chrome 时,我都需要重新加载我的网站。我们正在现代、MEAN 堆栈环境中重建一个古老的网站,我只是 知道 当它启动时我会收到投诉。
换句话说(危险:伪代码)-
if client closed chrome with site open
reauthenticate user
redirect to home page
我可以通过 express route 和 passport auth 完成最后两位,但是我如何检测客户端是否正在从他们的端加载缓存页面?
Is it possible to simply store some sort of js variable that is only set true after an actual login, or does Chrome keep that stored on close as well?
一个简单的例子来配合我的评论:
<html>
<head>
<script>
function DoMagic() {
document.getElementById( "magic" ).innerHTML = "<h1>Hello World!</h1>";
}
</script>
</head>
<body>
<div id="magic">Waiting for magic</div>
<br>
<input type="button" value="Do Magic" onclick="DoMagic();" />
</body>
</html>
- 在 Chrome 中打开此 div 显示 "Waiting for magic"。
- 单击 "Do Magic" div 读取 "Hello World"。
- 单击 X(不是页面,浏览器)关闭 Chrome。
- 打开 Chrome。页面加载。 Div 读取 "Waiting for magic."
状态不会在浏览器关闭之间保留——即使缓存是。我想你可以实现类似的东西来确保他们必须在浏览器关闭之间登录。应该也适用于所有浏览器。