JavaScript back to the previous page and go to the next page syntax
Sometimes you will see button options such as the previous or next page on a web page. There are usually two ways to do it. One is to directly assign the URL of the previous or next page to the button through PHP or other server-side programming languages. Another way is to use JavaScript history directly (of course, history can also be given a specific value).
JavaScript previous syntax
history.go(-1) // return to the previous page history.go(-2) // return to the previous two pages history.back() // return to the previous page
The -1 or -2 in the example can be modified according to your needs, or you can directly give the URL of the page you want to go to. Remember that if the browser does not record the previous page of the page, this way of writing is possible It will not be effective. In addition to returning to the previous page, JavaScript also has a way to go to the next page!
JavaScript Go to the next page of syntax
window.history.forward() //Go to the next page
Post a Comment
0 Comments