HTML/JAVASCRIPT 新手 Uncaught ReferenceError: xx is not defined
代码如下(自己在text文本上编辑 后讲文件名改为html后运行):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>Quotable Quotes</title>
<style type="text/javascript">
<!-- Hide the script from old browsers
function getQuote(){quotes=new Array(4);
sources=new Array(4);
quotes[0]="When I was a boy of 14,my father wa so "+"ignorant...but when I got to be 21,I was astonished...";
sources[0]="Mark Twain";
quotes[1]="Everybody is ignorant.Only on different "+"subjects.";
sources[1]="Will Roges";
quotes[2]="They say such nice things about people at "+"their funeral 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...";
sources[3]="Steven Wright";
i=Math.floor(Math.random() * quotes.length);
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>");
}
//stop hiding the script-->
</style>
</head>
<body>
<h1>Quotable Quotes</h1>
<p> Following is a random quotable quote.To see a new quotes just reload this page.</p>
<script type="text/javascript">
<!-- Hide the script from old browsers
getQuote();
//stop hiding the script-->
</script>
</body>
</html>
在IE和Google Chrome上运行,没有预期结果。查看开发者工具提示:Uncaught ReferenceError: getQuote is not defined
请问错在哪儿?