我是一个绝对的初学者,我正在尝试在任何浏览器(IE、FF、Chrome)中运行这段 JavaScript 代码。我正在使用 Firebug 作为调试器,但没有报告任何错误……感谢大家的宝贵时间。
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");
}