我是一個絕對的初學者,我試圖在任何瀏覽器(IE,FF,Chrome)中運行此JavaScript代碼。我使用Firebug作爲調試器,但沒有錯誤報告......我感謝你們所有的時間。JavaScript不會顯示在任何瀏覽器
function getQuote() {
// Create the arrays
quotes = new Arrays(4);
sources = new Arrays(4);
// Initialize the arrays with quotes
quotes[0] = "When I was a boy of 14, my father was so " + "ignorant...but when I got to be 21, I was astonished " + "at how much he had learned in 7 years.";
sources[0] = "Mark Twain";
quotes[1] = "Everybody is ignorant. Only on different " + "subjects.";
sources[1] = "Will Rogers";
quotes[2] = "They say such nice things about people at " + "their funerals that it makes me sad that I'm going to " + "miss mine by just a few days.";
sources[2] = "Garrison Keilor";
quotes[3] = "What's another word for thesaurus?";
sources[3] = "Steven Wright";
// Get a random index into the arrays
i = Math.floor(Math.random() * quotes.length);
// Write out the quote as HTML
document.write("<dl style='background-color: lightpink'>\n");
document.write("<dt>" + "\"<em>" + quotes[i] + "</em>\"\n");
document.write("<dd>" + "- " + sources[i] + "\n");
document.write("<dl>\n");
}
getQuote從哪裏調用? – smerny 2013-04-06 22:46:25
如果您不調用該函數,它將不會執行任何操作。 – 2013-04-06 22:46:45
除了使用'Arrays'而不是'Array'之外,除非您提供更多信息,否則無法確切地說出您的問題。請更新您的問題以提供問題的完整圖片。 – 2013-04-06 22:57:35