Detect when user clicks link, but aborts

后端 未结 6 1749
暖寄归人
暖寄归人 2020-12-07 03:15

I am working on a Web CMS. When the user clicks on a link to move to a different page, or submits a form, I want a "please wait" animated GIF to show up in the top

6条回答
  •  自闭症患者
    2020-12-07 03:48

    I think you should check so called "Anchor Navigation". There's a good tutorial here:

    http://yensdesign.com/2008/11/creating-ajax-websites-based-on-anchor-navigation/

    Basically, you will refer user to the same URL but with anchor in the end (http://localhost/home#somepage?param1=val1) and load the data using AJAX. Javascript will catch anchor change and can show "loading" icon and provide additional stuff like "cancel loading". In this case you will have your browser history in place, so you can say "back" in the browser or history.go(-1) in the javascript.

提交回复
热议问题