Back button triggers anchor click event – how to prevent it?

I show a loading animation on a site when the user clicks a link. I only want to display it in some cases and it works fine so far. However, it is also triggered when the user presses the back button and then the back action is prevented.

$('a').click (e) ->
  unless (window.keyIsDown or
    $(@).hasClass('share-btn') or
    $(@).attr('target') == '_blank' or
    $(@).attr('href').indexOf('mailto') > -1)
      $('.loading').show()

Why does showing a div prevent the back action from working? How can I enable the back action and still show the loading animation?


Source: cross-browser

Leave a Reply