开发者

window.onunload fires and then the user clicks stop

Here is the flow I am trying to figure out.

  • User hits my page.
  • Use开发者_运维知识库r clicks a link and onbeforeunload and unload get fired. Here i am getting rid of href in some of my links.
  • The page now hangs for a little bit giving the user a chance to hit the stop button in the browser.
  • Since the page is still on the original page (not the new page that was requested and then stopped) the hrefs are still blank.

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.


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜