Leonid
Leonid

Reputation: 1111

How can I call browser back or forward buttons using jquery?

Is it possible? And how can I call browser back function using jquery?

Upvotes: 14

Views: 18147

Answers (5)

JaySon
JaySon

Reputation: 377

Now, you could also do:

window.history.back() to go back, or
window.history.forward() to go forward.

Upvotes: 0

d.h.
d.h.

Reputation: 1206

JQuery makes sense to use when you want an unobtrusive way to display a browser back button. The following example will not display anything if javascript is disabled:

!function($){
$(document).ready(function(){
    $('#ELEMENT').append('<div class="browser_back"><a class="browser_back_link" alt="go one page back" title="go one page back" href="#browser_back">back</a></div>');
    $('#ELEMENT .browser_back a').click(function() {
    window.history.go(-1);
    return false;
    });
}); }(jQuery);

Upvotes: 1

Kris
Kris

Reputation: 41877

You don't need jquery for that:

  • forward: window.history.go(+1)
  • backward: window.history.go(-1)

Upvotes: 6

riffnl
riffnl

Reputation: 3183

why jquery? normal javascript support history.go(-1) or go(1) or look at: http://www.w3schools.com/jsref/met_his_back.asp and http://www.w3schools.com/jsref/met_his_forward.asp

Upvotes: 13

Daniel A. White
Daniel A. White

Reputation: 191058

You don't need JQuery for this.

history.go(-1); // go back
history.go(1); // go forward

Upvotes: 17

Related Questions