忍耐與我......我不是一個真正的開發人員,所以我確信我沒有以最好的方式去解決這個問題,我希望我們可以與我有我的工作,使其正常工作...Uncaught ReferenceError:函數未定義(匿名函數)
我有一個JS和PHP的組合,閃光燈屏幕上的圖像對,然後捕獲密鑰按下選擇左側或右側圖像(使用'c'和'm'或左箭頭和'右箭頭')。
它似乎在Safari,Firefox和IE瀏覽器上工作正常,但在Chrome中並不一致(有時它確實有時不會)。
我只是看着Chrome的檢查,同時運行它,並發現兩者的功能沒有被發現:
Uncaught ReferenceError: imgChoice is not defined (anonymous function)
Uncaught ReferenceError: stopChoice is not defined (anonymous function)
在我尋找答案,我得到的最接近是它可能是因爲Chrome正在快速處理flashImages()函數,而沒有進入其他兩個。
有沒有辦法解決這個問題?也許將imgChoice和stopChoice函數集成到flashImages函數中?
下面是現有功能:
function imgChoice(imgPair)
{
var imgDataR = '<input type="hidden" name="'+imgPair+'[<?php echo $_POST['topicNumber']; ?>]" value="r" />';
var imgDataL = '<input type="hidden" name="'+imgPair+'[<?php echo $_POST['topicNumber']; ?>]" value="l" />';
var noData = '<?php $noData = 1; ?>';
$(document).keydown(function(event) {
if (event.keyCode == 67 || event.keyCode == 37) {
document.getElementById(imgPair+'Data').innerHTML = imgDataL;
$(document).unbind('keydown');
}
if (event.keyCode == 77 || event.keyCode == 39) {
document.getElementById(imgPair+'Data').innerHTML = imgDataR;
$(document).unbind('keydown');
}
});
//div = document.getElementById(imgPair);
}
function stopChoice(imgPair)
{
$(document).unbind('keydown');
}
function flashImages()
{
i=500;
//$('#startTopic').fadeOut(500);
setTimeout("document.getElementById('fullpd').style.cursor='none';",50);
setTimeout("document.getElementById('fullpd').style.background='#464646';",500);
for(x=1;x<=imgPairs.length-1;x++)
{
setTimeout("document.getElementById('clickSound').play();",i+2000);
setTimeout('document.getElementById("'+imgPairs[x]+'").style.display="block";',i+3500)
setTimeout('imgChoice("'+imgPairs[x]+'");',i+3495)
setTimeout('document.getElementById("'+imgPairs[x]+'").style.display="none";',i+4000)
setTimeout('stopChoice("'+imgPairs[x]+'");',i+6000)
i=i+4000;
}
setTimeout("document.getElementById('fullpd').style.background='#eaeaea';",i+1000)
setTimeout("document.getElementById('fullpd').style.cursor='default';",i)
setTimeout(function() {$('#endTopic').fadeIn(1000);},i+1000);
}
你需要表現出更多的語境 - 似乎問題並不在那裏 – Alexander