我是JavaScript新手,一直在修改從JavaScriptKit開始的非安全JavaScript測驗,主要是整理在JSLint和Firebug中,並試圖讓它在Safari上工作(專門用於iPad) 。測驗在IE9,Chrome和Firefox中非常有用。Safari中的JavaScript文檔textarea問題
經過三天的時間和論壇的幫助,問題已被縮小爲JavaScript方法parse
被用作變量! Safari JavaScript的調試返回
ReferenceError: Can't find variable parse
這有道理(雖然爲什麼其他瀏覽器似乎不關心是奇怪的)。目前的版本有一些警報,可用here,錯誤發生在results.htm
頁面。
該函數在下面,我不知道如何解決它。我將parse
更改爲parced
,其他名稱只是需要變量才能使其在所有瀏覽器中失敗!我實際上並沒有理解文檔如何將這些信息寫入文本區域,只是它在三種瀏覽器中起作用,如魔術般的!任何幫助,將不勝感激。
var wrong = 0;
var e, n, results, temp, totalquestions;
for (e = 0; e <= 2; e++) {
document.result[e].value = "";
}
var results = document.cookie.split(";");
alert("var results = " + results);
for (n = 0; n <= results.length - 1; n++) {
alert("results length = " + results.length); <!--last alert in Safari -->
if (results[n].charAt(1) === 'q') {
parse = n;
alert("parse = " + parse);
}
}
var incorrect = results[parse].split("=");
alert("var incorrect = " + incorrect);
incorrect = incorrect[1].split("/");
alert("var incorrect after split = " + incorrect);
if (incorrect[incorrect.length - 1] === 'b') {
incorrect = "";
}
document.result[0].value = totalquestions - incorrect.length + " out of " + totalquestions;
document.result[2].value = ((totalquestions - incorrect.length)/totalquestions * 100).toFixed() + "%";
for (temp = 0; temp < incorrect.length; temp++) {
document.result[1].value += incorrect[temp] + ", ";
alert("the value of temp is " + temp);
}
感謝邁克,我會改變它的名字,因爲它是一種方法,並且按照您的建議進行聲明!手指交叉並感謝! – user1344843