yunzen
yunzen

Reputation: 33439

Stop navigation AFTER link has been clicked

Now, when I click on another inactive link after an active link is clicked, the browser will still got to the active link's url.

So the question is: How can I abort/stop/cancel a link navigation, after the link was pressed? I.E. my browser is already working.
The question is not: How can I prevent the link to be followed, if I click on the link?


jQuery('a.button').on('click', function(e){
    if ( jQuery(this).hasClass('active') ) {
        // no preventDefault(), so link is followed
        return;
    }
    e.preventDefault();
    // how can I stop the link from above?
    // ..
    jQuery(this).addClass('active')
    // do the slide thing
});

Upvotes: 0

Views: 1004

Answers (1)

SteamDev
SteamDev

Reputation: 4404

Sounds like what you're trying to do is window.stop().

https://developer.mozilla.org/en-US/docs/Web/API/Window/stop

The stop() method is exactly equivalent to clicking the stop button in the browser. Because of the order in which scripts are loaded, the stop() method cannot stop the document in which it is contained from loading, but it will stop the loading of large images, new windows, and other objects whose loading is deferred.

Upvotes: 3

Related Questions