onbeforeunload 也可以刷新 [英] onbeforeunload works also with refreshing
问题描述
我几天前做了这个问题(页面刷新后删除了 Java 会话) 而我没有答案.也许是因为问题出在 onbeforeunload 事件中.与:
I did this question few days ago (Java session deleted after page refresh) and I didn't have an answer. Maybe because the problem was in the onbeforeunload event. with:
<body onbeforeunload="chiudi()">
我想参加会议.问题是这样的会话将是
如果用户刷新页面,也会被扫描.我该如何解决?
I would like to rifle the session. The problem is that in this way the session will be
rifled also if the user refresh the page. How can I fix it?
这是我的 javascript 函数 chiudi()
Here's my javascript function chiudi()
function chiudi(){
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "SvuotaSession", false);
xmlHttp.setRequestHeader("Content-type",
"application/x-www-form-urlencoded");
xmlHttp.send(null);
}
推荐答案
我不认为你可以.不允许您获取有关用户要去哪里的信息(根据 this),所以没有办法知道用户正在刷新当前页面.
I don't think you can. You aren't allowed to get information about where the user is going to (according to this), so there isn't a way to know that the user is refreshing the current page.
这篇关于onbeforeunload 也可以刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!