各位看看这句是否有什么问题???
doc.writeln('<a href="engines.htm" ')
doc.writeln('onClick="setSearch(\''+topics[n][i].search+'\')">')
执行后把原代码显示出来了,如下:
a href="engines.htm" onClick="setSearch(javascript documentation)"> documentation
a href="engines.htm" onClick="setSearch(javascript tutorial)"> tutorials
a href="engines.htm" onClick="setSearch(javascript example)"> examples
按理应该显示出链接的,各位看看出了什么问题????
全程序如下:
<html>
<head>
<title>topic</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function Topic(desc,search){
this.desc=desc
this.search=search
}
topics=new Array()
topics[0]=new Array(
new Topic("tuthorials","cgi tutorial"),
new Topic("documentation","cgi documentation"),
new Topic("examples","cgi example"),
new Topic("using cookies","cgi cookies")
)
topics[1]=new Array(
new Topic("html 2.0","html 2.0"),
new Topic("html 3.0","html 3.0"),
new Topic("html 3.2","html 3.2"),
new Topic("extensions","html extensions"),
new Topic("tutorials","html turorial")
)
topics[2]=new Array(
new Topic("specification","http specification"),
new Topic("security","http security"),
new Topic("versions","http version")
)
topics[3]=new Array(
new Topic("documentation","java documentation"),
new Topic("tutorials","java tutorial"),
new Topic("examples","java example"),
new Topic("shareware","java shareware")
)
topics[4]=new Array(
new Topic("documentation","javascript documentation"),
new Topic("tutorials","javascript tutorial"),
new Topic("examples","javascript example")
)
topics[5]=new Array(
new Topic("documentation","vrml documentation"),
new Topic("tutorials","vrml tutorial"),
new Topic("examples","vrml example"),
new Topic("web sites","vrml sites")
)
function processArea(){
var thisForm=window.document.forms[0]
var elements=thisForm.elements
for(var i=0;i<topics.length;++i){
if(elements[i].checked) displayTopics(i)
}
}
function displayTopics(n){
var doc=parent.frames[1].document
doc.open()
doc.writeln('<html>')
doc.writeln('<head>')
doc.writeln('<script Language="JavaScript">')
doc.writeln('function setSearch(s){ ')
doc.writeln('text=parent.frames[0].document.forms[0].srch')
doc.writeln('text.value=s ')
doc.writeln('}')
doc.writeln('</script></head><body bgcolor= "green">')
doc.writeln('<h2>select a topic:</h2>' )
for (var i=0;i<topics[n].length;++i )
{
doc.writeln('<a href="engines.htm" ')
doc.writeln('onClick="setSearch(\''+topics[n][i].search+'\')">')
doc.writeln(topics[n][i].desc+'</a><p></p>')
}
doc.writeln('</body>')
doc.writeln('</html>')
doc.close()
}
//--></script>
</head>
<body bgcolor="blue">
<form>
<h2>select a technology area:</h2>
<table>
<tr><td><p>
<input type="radio" name="area" value="cgi" onClick="processArea()"> cgi</p></td>
<td><p>
<input type="radio" name="area" value="html"
onClick="processArea()">html</p></td>
<td><p>
<input type="radio" name="area" value="http"
onClick="processArea()">http</p></td>
</tr>
<tr><td><p>
<input type="radio" name="area" value="java"
onClick="processArea()"> java </p></td>
<td><p>
<input type="radio" name="area" value="javascript"
checked="checked" onClick="processArea()">javascript</p></td>
<td><p>
<input type="radio" name="area" value="vrml" onClick="processArea()">vrml</p></td>
</tr>
</table>
<input type="text" name="srch" size="40">
</form>
<script language="javascript"><!--
processArea()
//--></script>
</body>
</html>