Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable/disable "click to go forward" button in browser using history js?

Using history.pushState, we can change the current url using history API. Using popstate function, we can get back to previous page. But while going back, I found that the forward link button in browser "Click here to go forward" gets disabled. Now, using history, I need to access that button's property.

How can we access the forward button's url using history API?

like image 474
Ganesh Babu Avatar asked May 05 '14 14:05

Ganesh Babu


1 Answers

Are you manually popping the state? It sounds like it's getting removed.

To go back, you should be using history.back(). history.back() will preserve the entry in history so that you'll see the forward button enabled to go back forward.

You can also specify how many entries to go back with history.go(X). ex: history.go(-3) will take you back three pages.

Source: MDN

like image 127
Etai Avatar answered Nov 02 '22 03:11

Etai