# Go back 2 pages on click

**URL:** https://community.weweb.io/t/go-back-2-pages-on-click/14494
**Category:** How do I?
**Created:** [November 12, 2024, 3:34pm UTC](https://community.weweb.io/t/go-back-2-pages-on-click/14494 "2024-11-12T15:34:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Adam](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/adam/32/9449_2.png) [@Adam](https://community.weweb.io/u/Adam)
#### Post date: [November 12, 2024, 3:34pm UTC](https://community.weweb.io/t/go-back-2-pages-on-click/14494/1 "2024-11-12T15:34:16Z")

</div>

Hi,  
In certain flows, I have a intermediate page that forks to either a preview page or full page depending on whether a user is subscribed or not.  
The only problem is, if they try to click “back” on whatever page they end up, it redirects them to the “forking” page, which then redirects them again to the same final page they were just on.

Is there a way to go back 2 pages when the user clicks “back” so that they end up where then intend?

---

<div class="post-metadata">

### Author: ![what.gift](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/what.gift/32/8069_2.png) [@what.gift](https://community.weweb.io/u/what.gift)
#### Post date: [November 12, 2024, 11:10pm UTC](https://community.weweb.io/t/go-back-2-pages-on-click/14494/2 "2024-11-12T23:10:22Z")

</div>

Simple. Store the page in a variable. Use customJS to save:

```auto
return window.location.href

```

You can see how I handle this on [what.gift](https://www.what.gift/en/gb/gift-guide/) when you click a gift. It loads a modal and the URL in the browser changes and then when it closes, it reverts back. It’s not changing a page, but editing the browser url should a user want to save/share that URL it’ll correctly navigate them to the right page.

---

<div class="post-metadata">

### Author: ![Adam](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/adam/32/9449_2.png) [@Adam](https://community.weweb.io/u/Adam)
#### Post date: [November 14, 2024, 9:20am UTC](https://community.weweb.io/t/go-back-2-pages-on-click/14494/3 "2024-11-14T09:20:47Z")

</div>

Storing the page got complicated in my case, because I would need to store a chain of previous pages in some circumstances.  
Instead, I made a custom. back button for this specific page and used the following custom JS when the custom back button is clicked  
`history.go(-2)`
