Languages
[Edit]
EN

JavaScript - navigate multiple pages back

3 points
Created by:
Aston-Freeman
427

In this article, we would like to show you how to navigate multiple pages back using JavaScript.

Quick solution:

// ONLINE-RUNNER:browser;

<button onclick="history.go(-2)">
  Navigate 2 pages back
</button>

 

Practical example

In this example, we use history.go(-2) to navigate two pages back.

// ONLINE-RUNNER:browser;

<!DOCTYPE html>
<html>
<body>
  <button onclick="history.go(-2)">
    Navigate 2 pages back
  </button>
</body>
</html>

Note:

Change the history.go() argument value to navigate one (-1), three (-3) etc. pages back. 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join