开发者

Detect if the user clicks the Browsers Back Button - Have jQuery on page

开发者 https://www.devze.com 2023-04-05 03:56 出处:网络
there are a bunch of posts on this topic, but my situation is a bit odd. I have a Google Map. As you mo开发者_开发知识库ve around the map the Latitude, Longitude and Zoom are added to the URL after t

there are a bunch of posts on this topic, but my situation is a bit odd.

I have a Google Map. As you mo开发者_开发知识库ve around the map the Latitude, Longitude and Zoom are added to the URL after the hash symbol. The URL updates on the Google Map "Idle" event. If a user cuts/pastes the URL with the Hash into another browser, the map will zoom and pan to the location stored in the hash.

The browser history stores each URL with the hash as a user plays with the map. Hitting the back button will show the old URL, and it would be easy to update the current view based on the data in the URL. BUT the problem is I need to be able to tell if the hash changed because the user dragged/zoomed the map or hit the back button?

For example, if I could capture the back button event, I could call updateView() on the map.


use window.onbeforeunload


edit: nvm, i dont think this will take into consideration backing out a hash..

0

精彩评论

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

关注公众号