简体   繁体   中英

manipulate browsing history programmatically

I'm developing a shopping site

User moves from

product-detail -> cart -> checkout steps -> order confirm

When a user arrives order confirm page, if he hits back button, I think he should go to the page before the cart which is product-detail page in the above flow.

  • edit

He might go back and forth between cart and checkout steps.

I guess I need a way to mark these pages for deletion.

Does history api offer a way to mark pages so that later one can remove them from the history?

If you use this:

window.history.go(-3); //jumps back 3 in the history

And the user then browses to a new page, it will delete the forward history. So, to prevent browsing forward you could go back further and then forward.

window.history.go(-4); //jumps back 3 in the history

window.history.go(1); //erase the history

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM