开发者

How detect "refresh" event with prototype?

开发者 https://www.devze.com 2023-03-19 09:24 出处:网络
How detect \"refresh\" 开发者_运维技巧event with prototype? A Cross-browser solution? Thanks, CelsoThere\'s no way to detect refreshes in particular, but you can catch the browser before the page get

How detect "refresh" 开发者_运维技巧event with prototype? A Cross-browser solution?

Thanks, Celso


There's no way to detect refreshes in particular, but you can catch the browser before the page gets unloaded (which happens when the user refreshes the page - as well as when they 'move' to another page)

In prototype this would look something like this:

Event.observe(window, 'beforeunload', yourFunction);

If you need to tell the difference, you could always bind some code to the links on your page that disables the above binding so that when the user actively clicks something you know it's a link (and not a refresh).

0

精彩评论

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