HTML/JAVASCRIPT 新手 Uncaught ReferenceError: xx is not defined

jsonnode 2014-07-04 04:29:12
代码如下(自己在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

请问错在哪儿?
...全文
679 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
bbjbepzz 2014-07-04
  • 打赏
  • 举报
回复
<style type="text/javascript"> js的标签是<script>

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧