javascript slideshow that loads new page after last slide -
sorry, i'm quite new js. have basic html page i've put in slideshow advances slide each click. want have happen have change new page when user clicks next , on last slide. html:
<div id="images"> <img id="image1" src="http://www.lorempixel.com/960/580/sports" /> <img id="image2" src="http://www.lorempixel.com/960/580/cats" /> <img id="image3" src="http://www.lorempixel.com/960/580/food" /> <img id="image4" src="http://www.lorempixel.com/960/580/people" /> </div>
and js looks this:
var max = 4; function gotonext() { var hash = string(document.location.hash); if (hash && hash.indexof(/image/)) { var newh = number(hash.replace("#image", "")); (newh > max - 1) ? newh = 0 : void(null); document.location.hash = "#image" + string(newh + 1); } else { document.location.hash = "image1"; } } function gotoprevious() { var hash = string(document.location.hash); if (hash && hash.indexof(/image/)) { var newh = number(hash.replace("#image", "")); (newh == 1) ? newh = 5 : void(null); document.location.hash = "#image" + string(newh - 1); } else { var url = window.location.href; if (url.search("#image") > 0) { window.location.href = "strategy.html"; } } }
change this:
(newh > max - 1) ? newh = 0 : void(null); document.location.hash = "#image" + string(newh + 1);
to this:
(newh > max - 1) ? window.location.href = "strategy.html" : document.location.hash = "#image" + string(newh + 1);
Comments
Post a Comment