2016-06-21 36 views
0

對不起,我在這裏遇到了一些特殊問題,可能對其他人沒有太大幫助。或者也許不知何故,它可能是,我不知道。我在隨機圖片的幻燈片中顯示的最終圖片不顯示

我一直在搞這個整晚,它在吹我的腦海,因爲圖像全部消失,因爲它們應該,一切都會改變,完全轉換到最後,最後的圖像會顯示「感謝您觀看「顯示,除非不是。這很奇怪,因爲標題像它應該是空白的,我甚至在圖像設置完成後運行警報,並且它會觸發。在我投入褪色之前,最終幻燈片正在顯示。所以我覺得這是因爲它被淡化了,所以我在它下面放了一個淡色,但是沒有做任何事。我不知道,我很茫然。

這是我的網站給你一個這裏發生了什麼的想法。 http://www.dreamquest.io

/* this is the first function that is fired though I've moved it after the next function just 
to be chronological, but no luck with the issue at hand */ 
function removeImage(){ 
    document.getElementById("all").onclick = ""; 
    document.getElementById("remove").onclick = ""; 
    $("#image").fadeTo(2000,0, changeImage); 
} 

function changeImage(){ 
    var random = mix.pop(); 
    var entry = backInfo[random]; 
    if (random == undefined) { 
    document.getElementById("caption").textContent = ""; 
    /* end.png is the last image in the slideshow that isn't showing up */ 
    document.getElementById("image").src = "end.png"; 
    $("#image").fadeTo(1000,1); 
    } 
    document.body.style.textShadow = "1px 1px 7px #000"; 
    document.getElementById("all").style.backgroundImage = "url(" + entry.image + ")"; 
    document.getElementById("image").src = entry.image; 
    document.getElementById("artist").href = entry.artist; 
    document.getElementById("caption").textContent = entry.caption; 
    if (random != undefined) { 
    /* I've even amde sure that random is in fact undefined at the last slide */ 
    var image = new Image(); 
    image.onload = function() { 
     $("#image").fadeTo(1000,1); 
     document.getElementById("all").onclick = removeImage; 
     document.getElementById("remove").onclick = removeImage; 
    } 
    image.src = entry.image; 
    } 
} 

回答

0

啊,所以,我認爲一旦入口是未定義的,它就停止運行從任何一點入口被引入的功能。我錯了。我認爲。但無論如何,我將它重新排序以隔離在定義隨機數時輸入條目的點,所以它無法覆蓋我的end.png,並且它工作正常!

function changeImage(){ 
    var random = mix.pop(); 
    var entry = backInfo[random]; 
    if (random == undefined) { 
    document.getElementById("caption").textContent = ""; 
    document.getElementById("image").src = "end.png"; 
    $("#image").fadeTo(1000,1); 
    } 
    if (random != undefined) { 
    var image = new Image(); 
    image.onload = function() { 
     $("#image").fadeTo(1000,1); 
     document.getElementById("all").onclick = removeImage; 
     document.getElementById("remove").onclick = removeImage; 
    } 
    image.src = entry.image; 
    document.body.style.textShadow = "1px 1px 7px #000"; 
    document.getElementById("all").style.backgroundImage = "url(" + entry.image + ")"; 
    document.getElementById("image").src = entry.image; 
    document.getElementById("artist").href = entry.artist; 
    document.getElementById("caption").textContent = entry.caption; 
    } 

} 

function removeImage(){ 
    document.getElementById("all").onclick = ""; 
    document.getElementById("remove").onclick = ""; 
    $("#image").fadeTo(2000,0, changeImage); 
} 
0

如果隨機是不確定的手段進入也是不確定因此,如何把檢查裏面像一個新的變種命名條目!

if (random == undefined) { 
    var entry = {image : "end.png", artist : "null", caption : "null"}; 
} 

而只是刪除

if (random != undefined) {} 

希望幫助!