How detect “refresh” event with prototype?

独自空忆成欢 提交于 2019-12-12 23:40:13

问题


How detect "refresh" event with prototype? A Cross-browser solution?

Thanks, Celso


回答1:


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).



来源:https://stackoverflow.com/questions/6627427/how-detect-refresh-event-with-prototype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!