Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

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

like image 923
Leonid Avatar asked Jan 27 '11 12:01

Leonid


People also ask

How do I get the browser back button event in JQuery?

You can simply fire the “popState” event in JQuery e.g: $(window). on('popstate', function(event) { alert("pop"); });

How can you disable browser forward and back button using JQuery?

function preventBack() { window. history. forward(); } window. onunload = function() { null; }; setTimeout("preventBack()", 0);

How do I go back in browser using JavaScript?

There is two popular way to make browsers go back to the previous page by clicking JavaScript event, both methods are described below: Method 1: Using history.go() method: The go() method of the window. history object is used to load a page from the session history.


1 Answers

You don't need JQuery for this.

history.go(-1); // go back
history.go(1); // go forward
like image 163
Daniel A. White Avatar answered Sep 23 '22 17:09

Daniel A. White