Forward and back button in JavaScript take user to previously open window or forward to next opened window in browser.
This works same as browser’s back and forward buttons work.
Back function can be done by
window.back()
history.back()
history.go()
Can jump more than one step by passing number of history back
history.go(-1) one step behind
history.go(-2) two step behind in history
Forward can use
history.forward()
Back history code
<input type="button" name="btn" value="Back" onclick="history.back()" />
<input type="button" name="btn" value="Back" onclick="window.back()" />
Forward button
<input type="button" name="btn" value="Forward" onclick="history.forward()" />
Demo




Link to Us