-1
因此,我一直無法將我的功能鏈接到我的網站。請記住,這是所有客戶端。這裏是我的JavaScript函數:需要幫助將JavaScript中的「隨機」功能鏈接到映射圖像
function RandomButton() {
var number=Math.floor((Math.random() * 3) + 1);
if(number===1) {
window.location.replace("../Mazerunner.html");
}
else if(number===2) {
window.location.replace("../GoneGirl.html");
}
else if(number===3) {
window.location.replace("../Dracula.html");
}
基本上所發生的事情是,它選擇1和3之間的隨機數,如果它的1它去到一個網頁,IFS其2另一頁等等。現在我不知道如何將其鏈接到我的映射圖像。這個功能甚至可能不會做我認爲它在JavaScript中做的很新的事情。這是我的圖像地圖代碼。
<map name="RandomMap">
<area shape="rect" coords="0,0,500,500" onclick="RandomButton()" href="" alt="Random">
</map>
我不知道該怎麼做與href =「」,因爲我得到一個錯誤,如果我只是刪除它。
你沒有一個'}'關閉您的功能。您可能忘了在複製代碼並粘貼時忘記添加它。 – 2014-11-20 21:16:27