Have the back-link append the ID of the target slide to the URL:
<a href="index.html#slide3">Back</a>
Then use
the location.hash
property[
^] to determine which slide to start on:
var timer = null;
var slideIndex = getInitialSlideIndex();
showSlides(slideIndex);
function getInitialSlideIndex(){
var index = 1;
var hash = location.hash;
if (hash) {
var slideId = hash.substr(1);
var slides = document.getElementsByClassName("mySlides");
for (var i = 0; i < slides.length; i++){
if (slides[i].id === slideId) {
index = i + 1;
break;
}
}
}
return index;
}