re1man
re1man

Reputation: 2367

activate events onclick of browser's back button in jquery

Im looking for a simple cross-browser plugin or method that can help me do this :

$('#clear_window').click(function(){
    $('#window').fadeOut(50);
        var activeTab = $("ul.tabs li.active").find("a").attr("href");
        $(activeTab).fadeIn(50);
});

but on the click of the browsers back button not on the #clear_window click

Upvotes: 0

Views: 953

Answers (2)

Arturo Sevilla
Arturo Sevilla

Reputation: 227

You can through HTML5 History API. But this only supported by Gecko (Firefox), Chrome and Internet Explorer 10+

For what you want you can read it in MDN documentation.

However, if you can how your application handle your URLs, then you can implement it through the hashchange event, similar to how this jQuery plugin handles it.

Upvotes: 1

Moe Sweet
Moe Sweet

Reputation: 3721

You cannot detect broswer's back button click. The only way to do is to detect "leave page" event. This might help... Best way to detect when a user leaves a web page?

Upvotes: 0

Related Questions