各位看看这句是否有什么问题???

ccssme 2002-06-16 06:03:58
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>
...全文
111 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xp3 2002-06-27
  • 打赏
  • 举报
回复
错了,NEWMUNG 你的分在另一个地方领!!请看你接的贴!!
ccssme 2002-06-27
  • 打赏
  • 举报
回复
newmung(迷途浪人):请到这来领你的80分.
ccssme 2002-06-16
  • 打赏
  • 举报
回复
net_lover(孟子E章) 按你说的方法改了一下,还是老样子,我惯于怀疑是下面两句的问题,但不怎么改???0
doc.writeln('<a href="engines.htm" ')
doc.writeln('onClick="setSearch(\''+topics[n][i].search+'\')">')
doc.writeln(topics[n][i].desc+'</a><p></p>')
ccssme 2002-06-16
  • 打赏
  • 举报
回复

可是调用它的还有其他窗体,我把全部的代码放上:
主程序:search.htm
<html>
<head>
<title>web technology search page</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<frameset rows="250,*" border="10">
<frame src="sform.htm">
<frame src="blank.htm">
</frameset><noframes></noframes>
</html>

sform.htm
<html>
<head>
<title>Untitled Document</title>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<frameset cols="*,*" border="5">
<frame src="topic.htm">
<frame src="blank.htm">
</frameset><noframes></noframes>

</html>

上面那个是topic.htm

还有一个engines.htm
<html>
<head>
<title>web search engines</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript"><!--
function goSearch()
{
doc=top.frames[1].document
doc.write("<h2> this function is implemented in ">
doc.write("<code>engines2.htm</code> and ")
doc.writeln("<code> engines3.htm</code>.</h2>")
}
//--></script>

</head>

<body bgcolor="red">
<h2>web search engines:</h2>
<form>
<table>
<tr>
<td><input type="checkbox" checked name="infoseek">infoseek</td>
<td><input type="checkbox" checked name="excite">excite</td>
<td><input type="checkbox" checked name="yahoo">yahoo</td>
</tr>
<tr>
<td><input type="checked" checked name="magellan"> magellan
</td>
<td><input type="checked" checked name="altavista">alta vista
</td>
<td><input type="checked" checked name="lycos">
lycos </td>
</tr>
</table>
<p><input type="button" value="go for it!" onClick="goSearch()"></p>
</form>

</body>
</html>
这下就全了,看看是什么问题吧!!我都都 找了一天了!!
孟子E章 2002-06-16
  • 打赏
  • 举报
回复
我的浏览器没有问题
孟子E章 2002-06-16
  • 打赏
  • 举报
回复
问题出在:var doc=parent.frames[1].document里,请仔细检查
下面这样就没有问题的呀

<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=window.open().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>

87,996

社区成员

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

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