注意:此代碼適用於所有瀏覽器BESIDES Firefox,是的, m使用最新版本。Javascript BlackJack腳本沒有在Mozilla Firefox中的按鈕執行/調用「hitMe()」和「stand()」功能
注意:我只包括有問題的代碼,其他一切工作正常。
當我編寫下面的代碼時,Firefox會加載其他一切正常。
瀏覽器會接受第一個按鈕功能(一個按鈕調用的功能),但不接受第二個或第三個按鈕功能。
未提供給我的代碼中包含的「優惠」按鈕正常工作。它打印一個新頁面。
現在當打印新頁面時,出現「點擊」和「站立」按鈕。問題是...
...這些按鈕不會像「Deal」按鈕那樣打印新頁面。
我相信問題是要定義的功能或其內部的內容。
//**** STAND FUNCTION START DEALS DEALER CARDS ****
function stand()
/*Altough we have a "printCards" function, we will print the cards
differently in the stand function. Why? When the first cards are printed,
we have a hidden one, thus showing the hidden card in this function*/
{
dealerAcesTotal = dealerTotal;
if (dealerAcesTotal == 22){(dealerAcesTotal = 12);}
//KEEP DEALING CARDS TO THE DEALER WHILE THE HAND IS UNDER 17
while (dealerAcesTotal < 17)
{
randA = Math.floor((Math.random()*52)+1);//for the dealer
dealerCards[dealerHits] = card[randA];
dealerTotal = (dealerTotal + dealerCards[dealerHits][3]);
if (dealerCards[dealerHits][3] == 11){dealerAces = (dealerAces + 1);}
dealerHits = (dealerHits + 1);
dealerAcesTotal = dealerTotal;
}
//end of KEEP DEALING CARDS TO THE DEALER
//add a new row for totals and DEAL button
document.write("</TR><TR><TD align=center><FONT color=white><kbd>Dealer = " + dealerAcesTotal + "</TD>");
document.write("<TD align=center><FONT color=white><kbd>Player = " + playerAcesTotal + "</TD>");
document.write("<TD align=center><FONT color=white><kbd>BET = $" + bet + "</TD>");
document.write("<TD align=center><FONT color=white><kbd>" + handText + "<BR>"+ name +"'s Bank: $" + currentBank + "</TD>");
document.write("<TD align=center><FONT color=white><kbd><button onclick=\"\dealCards \(\)\">Deal</button></TD>");
document.write("</TR><TR>");
//****END OF PRINT CARDS TO FINISH HAND SCREEN
document.close();
return;
}
//**END OF STAND FUNCTION**
function hitMe(){playerHit();} //a sort of test for the browser...
//****PLAYER HITS FOR A NEW CARD****
function playerHit()
{
randA = Math.floor((Math.random()*52)+1);//for the player
playerCards[playerHits] = card[randA];
playerTotal = (playerTotal + playerCards[playerHits][3]);
if (playerCards[playerHits][3] == 11){playerAces = (playerAces + 1);}
playerHits = (playerHits + 1);
playerAcesTotal = playerTotal;
// run a loop for as many aces in the hand
//if the playerTotal is over 21 deduc
for (i = 0; i< playerAces; i++)
{
if (playerAcesTotal > 21){playerAcesTotal = (playerAcesTotal - 10);}
}
printCards();
//document.close();
//return;
}
反饋將真正讚賞。 :)
PS:我的劇本是在當前頁面:http://ca1k.xkotto.com/portfolio/BLACKJACKV10.html
該問題可以通過清除緩存來解決。也許試試看? –
對不起,我已經嘗試過這種解決方案,但迄今爲止沒有任何進展,但感謝您爲幫助我所做的努力。 – CA1K
只是檢查了這一點https://support.mozilla.org/en-US/questions/751899 –