使用此HTML/Javascript/CSS生成随机字符串?

使用此HTML/Javascript/CSS生成随机字符串?,javascript,html,css,string,random,Javascript,Html,Css,String,Random,我已经摆弄这个HTML和javascript一两个小时了……我不明白为什么它不工作。我一直试图自己学习html、css和javascript……但我认为Eclipse并没有很好地调试我的东西……发生了什么事 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <style type="text/css"> a:link {color:#FF0000;} /*

我已经摆弄这个HTML和javascript一两个小时了……我不明白为什么它不工作。我一直试图自己学习html、css和javascript……但我认为Eclipse并没有很好地调试我的东西……发生了什么事

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<style type="text/css">
a:link {color:#FF0000;}    /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;}   /* mouse over link */
a:active {color:#0000FF;}  /* selected link */
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Catlard.com</title>

<link rel=StyleSheet href="styles/menuStyle.css" type="text/css"/>

<script type="text/javascript">

function RandomQuote()
{
    var quotes= new Array();
    quotes[0] = "...believes it may be useful in a time of need."
    quotes[1] = "...knows you have a problem, but accepts you anyway."
    quotes[2] = "...believes the aliens were involved at Oak Island."
    quotes[3] = "...demands to know the location of your hidden rebel base!"
    quotes[4] = "...SAW you take the cookie from the cookie jar."
    return quotes[Math.floor(Math.random() * 4.99);
}

</script>

</head>
<body>

<div id="framecontent">
<div class="innertube">
<h1>CSS Top Frame Layout</h1>
<span style="font-family : Courier;color: #000000;">
<a href="resume.html"> Resume </a>
<a href="http://catlard.blogspot.com"> Blog </a>
<a href="pixelating.html"> Arts n' Farts</a>
<a href="contact.html"> Contact </a>
<a href="typing.html"> Games </a>
</span>
</div>
</div>


<div id="maincontent">
<div class="innertube">

document.write(RandomQuote());
<p style="text-align: center">Blah blah blah </p>
</div>
</div>

</body>
</html>

a:link{color:#FF0000;}/*未访问的链接*/
a:已访问{color:#00FF00;}/*已访问链接*/
a:将{color:#FF00FF;}/*鼠标悬停在链接上*/
a:活动{color:#0000FF;}/*选定链接*/
卡特拉德网站
函数RandomQuote()
{
var quotes=新数组();
quotes[0]=“…相信它在需要时可能有用。”
quotes[1]=“…知道你有问题,但无论如何都接受你。”
quotes[2]=“……相信外星人与橡树岛有关。”
quotes[3]=“…要求知道你隐藏的叛军基地的位置!”
quotes[4]=“…看到你从饼干罐中取出饼干。”
返回引号[Math.floor(Math.random()*4.99);
}
CSS顶部框架布局
document.write(RandomQuote());

诸如此类


您在返回报价行上有一个错误。它应该以]结尾;不是),

此外,每个引号[n]行都应以分号结尾


而且,您应该在
script
标记中包含document.write()。

您的“document.write”行需要位于
区域中。您还缺少返回行上的“]”括号。

您需要更清楚地检查代码。也许可以使用语法突出显示编程编辑器,如SciTe

尽管你没有明确告诉我们你的问题(只是说它不起作用),但我首先想到的是这句话:

return quotes[Math.floor(Math.random() * 4.99);

您忘记了数组的结尾。

返回命令中缺少结尾。

两件事:

return quotes[Math.floor(Math.random() * 4.99)];
您缺少引号数组的结束标记

<script language="javascript" type="text/javascript">
    document.write(RandomQuote());
</script>

document.write(RandomQuote());

您的javascript必须包装在该脚本标记中,否则它将被呈现为HTML。

您没有告诉我们运行此脚本时会发生什么。怎么了?啊,对不起。当我运行它时,它在我调用函数的浏览器中不显示任何内容。因为您不调用代码。它的格式是文本。尝试将其放入另一个脚本标记中-1因为缺少r-?对不起,我有点困惑。+1代表勇敢但徒劳的尝试,通过添加神秘的“r”来修复。啊,这是完全正确的。我做了所有这些事情,现在一切都正常了。我为我所有的语法错误道歉——我没有一个很好的IDE——我现在正在使用Eclipse for Javascript。对OSX 32位的初学者有什么建议吗?啊,是的,没错。非常感谢你。我将检查SciTe,而不是eclipse。干杯!谢谢这是一个大问题。