简体   繁体   中英

replicate what the back button on the browser does… EXACTLY

as the title suggests, I'd like to click on something on my website, and have it do EXACTLY the same thing as the back button.

I have tried window.history.go(-1) which seems to be going back 2 pages as opposed to 1 on all browsers except firefox where it seems to work.

The back button on any browser at all, does exactly what I want. returns to the previous page, showing the same page data from before. Any ideas why window.history.go(-1) would go back twice, and any idea if there is another way that mimics the back button EXACTLY?

Thanks

Try using window.history.back();

See here

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