[英]window.onunload fires and then the user clicks stop
Here is the flow I am trying to figure out.这是我试图弄清楚的流程。
onbeforeunload
and unload
get fired.onbeforeunload
和unload
。 Here i am getting rid of href in some of my links. Is there any way of knowing if the user clicks a stop button and they are still on the same page?有没有办法知道用户是否点击了停止按钮并且他们仍然在同一页面上?
The only way I can think off the top of my head is to put a setTimeout in the onbeforeunload
or unload
but I don't really like that because there are too many variables for it still being messed up.我能想到的唯一方法是在
onbeforeunload
或unload
中放置一个 setTimeout ,但我真的不喜欢这样,因为变量太多,它仍然被搞砸了。
What I ended up doing was this:我最终做的是:
window.unload = function(){
var _href = $('selector').attr('href');
$('selector').attr('href', '');
setTimeout(function(){
$('selector').attr('href', _href);
}, 1500);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.