在最后一张幻灯片之后加载新页面的javascript幻灯片

在最后一张幻灯片之后加载新页面的javascript幻灯片,javascript,slideshow,Javascript,Slideshow,对不起,我对JS还很陌生。我有一个基本的html页面,在那里我放了一个幻灯片,每次点击都会推进幻灯片。我想做的是,当用户单击“下一步”并在最后一张幻灯片上时,将其更改为新页面。我的html: <div id="images"> <img id="image1" src="http://www.lorempixel.com/960/580/sports" /> <img id="image2" src="http://www.lorempixel.co

对不起,我对JS还很陌生。我有一个基本的html页面,在那里我放了一个幻灯片,每次点击都会推进幻灯片。我想做的是,当用户单击“下一步”并在最后一张幻灯片上时,将其更改为新页面。我的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>
更改此项:

(newh > max - 1) ? newh = 0 : void(null);
        document.location.hash = "#image" + String(newh + 1);
为此:

(newh > max - 1) ? window.location.href = "strategy.html" :
        document.location.hash = "#image" + String(newh + 1);

只要检查newh是否为零

    if(newh == 0) 
        document.location.href = "strategy.html";
这是全部代码

    if(newh == 0) 
        document.location.href = "strategy.html";
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);

        if(newh == 0) 
            document.location.href = "strategy.html";
        else 
            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 = max+1 : void(null);
        document.location.hash = "#image" + String(newh - 1);
    } else {
        document.location.hash = "image4";    
 }
}