我有一個似乎很簡單的問題,但我似乎無法找到關於我的問題的任何資源。我想要做的是將36個圖像從計算機內的文件夾存儲到使用Javascript的數組中。以下是相關代碼片段的簡短版本。Javascript;從保存文件夾圖像陣列
<!doctype html>
<head>
<style>
div#GameBoard {
position: absolute;
top: 66px;
left: 53px;
display: block;
margin: 10px;
padding: 10px;
border: ridge #7CFC00 15px;
width: 1007px;
height: 698px;
}
div#Flipper {
display: block;
position: relative;
background-color: #000;
}
<style>
<script lang="javascript">
var ImgArray = [[11-16][21-26][31-36][41-46][51-56][61-66]];
// pseudocode, the first digit is for row, second digit is for column number.
//I've named the pictures accordingly within the folder as 11.png,12.png,21.png,
//and within the array //as well.
function OnClickCard(path)
{
path || path ='C:\Users\Jamal\Desktop\codefolder\memorygame\gameimages'
document.getElementById("Flipper").img.src = ImgArray.splice(Math.floor(Math.random() * ImgArray.length)[ImgArray];
}
</script>
<body>
<div id="GameBoard">
<div class="Tile" id="Flipper">
<img name ="11" src="blue-glass-tile.png" onclick="OnClickCard()"/>
</div>
</body>
</head>
</html>
所以,我希望它做的是保存裏面的圖片36「C:\用戶\賈馬爾\桌面\ codefolder \ memorygame \ gameimages」內的陣列,並拼接0-35隨機指數改變到圖像源在div,除去該索引使得它不會被使用兩次。
究竟發生了什麼..沒什麼。我一直在運行在Firefox的開發者控制檯,並清除了所有的錯誤,但硬是沒有任何反應。我不知道如何運行控制檯日誌來檢測圖像是否已加載的錯誤。我很茫然,甚至已經跳到了邏輯。在這個時候,我迫切需要完成隨機程序,這使我瘋狂。我非常感謝您可能有的任何輸入。