Back to previous page javascript
Window history.back()ExampleCreate a back button on a page: Show The output of the code above will be: Click on Go Back to see how it works. Try it Yourself » Definition and UsageThe
The SyntaxParametersReturn ValueBrowser Support
Is there a function I can attach as a click event of a button to make the browser go back to previous page?
asked Nov 9, 2011 at 15:43
Doc HolidayDoc Holiday 9,59831 gold badges96 silver badges150 bronze badges 1 Add this in your input element
kartikluke 2,2971 gold badge18 silver badges32 bronze badges answered Nov 9, 2011 at 15:45
6
or
Put this to the button
ˈvɔlə 8,1079 gold badges60 silver badges82 bronze badges answered Nov 9, 2011 at 15:44
VadimVadim 5,0142 gold badges19 silver badges18 bronze badges 4 For Going to previous page First Method
Second Method
if we want to more than one step back then increase
answered Jun 3, 2013 at 10:52
Rizwan GillRizwan Gill 2,1431 gold badge16 silver badges27 bronze badges 1
answered Nov 9, 2011 at 15:44
hspainhspain 17.5k5 gold badges18 silver badges31 bronze badges 0 Simple. One line.
Like Wim's and Malik's answer, but just in one line. answered May 12, 2018 at 20:01
1 Shortest Yet!
http://jsfiddle.net/qXrbx/ I prefer the Also, using a tag for a back button seems more appropriate than tags with names and types... answered Nov 9, 2011 at 16:14
Michael DurrantMichael Durrant 90.7k91 gold badges311 silver badges475 bronze badges 0
answered Nov 29, 2016 at 10:05
Malik KhalilMalik Khalil 6,0052 gold badges38 silver badges32 bronze badges Works for me everytime
CroMagnon 1,1987 gold badges20 silver badges32 bronze badges answered Oct 14, 2019 at 13:04
You just need to call the following:
answered Nov 9, 2011 at 15:44
Rich O'KellyRich O'Kelly 40.6k9 gold badges83 silver badges113 bronze badges This is the only thing that works on all current browsers:
answered Jan 26, 2017 at 13:57
Wim MostreyWim Mostrey 2675 silver badges8 bronze badges Access
answered Aug 24, 2021 at 12:31
1 the only one that worked for me:
answered Feb 17, 2021 at 18:15
DevTheJoDevTheJo 2,0192 gold badges20 silver badges22 bronze badges You could use one of the following :
You also go back to N number of pages with this one
answered Sep 3 at 23:48
2 100% work
answered Jul 30, 2020 at 2:37
Fezal halaiFezal halai 7027 silver badges12 bronze badges How do I go back to previous page in JavaScript?The history. back() method loads the previous URL (page) in the history list. The history. back() method only works if a previous page exists.
How do I go back to previous page?Move between screens, webpages & apps
Gesture navigation: Swipe from the left or right edge of the screen. 2-button navigation: Tap Back . 3-button navigation: Tap Back .
How do I go back to previous page on button click?You can use the history. back() method to tell the browser to go back to the user's previous page. One way to use this JavaScript is to add it to the onclick event attribute of a button. Here, we create the button using a
What is history back ()?The History. back() method causes the browser to move back one page in the session history. It has the same effect as calling history.go(-1) . If there is no previous page, this method call does nothing. This method is asynchronous.
|