I'm creating an image slider in css3 with the :target selector. I have a next and previous button that are executing this line of javascript
window.location = "#image" + image;
The problem is that if i click the back button of my browser, it shows the previous image of the slider. I want the back button to go to the previous page, not the previous anchor.
Thanks for the help
window.location.replace("#image" + image);
This does a simple redirect without adding it to the history.
MDN: https://developer.mozilla.org/en-US/docs/Web/API/Location.replace
Previous question: What's the difference between window.location= and window.location.replace()?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With