<html><head><title>ceshi</title>
<script>
function listanchors(){
//打开新窗口
var newwin=window.open("","navwin","menubar=yes,scrollbars=yes,resizable=yes,width=600,height=300");
//赋给它标题
newwin.document.write("nav"+doument.title);
//裂出所有锚元素
for(var i=0;i<d.anchors.length;i++){
var a=d.anchors[i];
var text=null;
if(a.text) text=a.text;
else if(a.innerText) text=a.innerText;
if((text==null)||(text=='')) text=a.name;newwin.document.write('<a href="#'+a.name+'"'+'onclick="opener.location.hash="'+a.name+'";return false;">');
newwin.document.write(text);
newwin.writeln('</a><br>');
}
newwin.document.close();
}
</script></head><body>
<script>
document.name="wo";
</script>
<a name="i'm name1">this is 1 anchor</a>
<a name="i'm name2">this is 2 anchor</a>
<a href="a" onmouseover="listanchors('wo')">listanchors();</a>
</body></html>这个函数是权威指南上的函数,下面的调用是我自己写的,只能打开一个新窗口,但是是空白的,达不到想要的效果,为什么呢?大家帮我看下吧!没有分了,没办法啊。谢谢了!
<script>
function listanchors(){
//打开新窗口
var newwin=window.open("","navwin","menubar=yes,scrollbars=yes,resizable=yes,width=600,height=300");
//赋给它标题
newwin.document.write("nav"+doument.title);
//裂出所有锚元素
for(var i=0;i<d.anchors.length;i++){
var a=d.anchors[i];
var text=null;
if(a.text) text=a.text;
else if(a.innerText) text=a.innerText;
if((text==null)||(text=='')) text=a.name;newwin.document.write('<a href="#'+a.name+'"'+'onclick="opener.location.hash="'+a.name+'";return false;">');
newwin.document.write(text);
newwin.writeln('</a><br>');
}
newwin.document.close();
}
</script></head><body>
<script>
document.name="wo";
</script>
<a name="i'm name1">this is 1 anchor</a>
<a name="i'm name2">this is 2 anchor</a>
<a href="a" onmouseover="listanchors('wo')">listanchors();</a>
</body></html>这个函数是权威指南上的函数,下面的调用是我自己写的,只能打开一个新窗口,但是是空白的,达不到想要的效果,为什么呢?大家帮我看下吧!没有分了,没办法啊。谢谢了!
name 里加空格和符号是很不好滴命名习惯!<html>
<head>
<title>ceshi </title>
<script>
function listanchors(){
//打开新窗口
var newwin=window.open("","navwin","menubar=yes,scrollbars=yes,resizable=yes,width=600,height=300");
//赋给它标题
newwin.document.write("nav"+document.title);
var d = document;
//裂出所有锚元素
for(var i=0;i <d.anchors.length;i++)
{
var a=d.anchors[i];
var text=null;
if(a.text) text=a.text;
else if(a.innerText) text=a.innerText;
if((text==null)¦(text== ' ')) text=a.name; newwin.document.write('<a href="#'+a.name+ '"' + ' onclick="opener.location.hash=" '+a.name+ '";return false;"> ');
newwin.document.write(text);
newwin.document.write(' </a > <br > ');
}
newwin.document.close();
}
</script> </head> <body>
<script >
document.name="wo";
</script>
<a name="imname1" >this is 1 anchor </a >
<a name="imname2" >this is 2 anchor </a >
<a href="a" onmouseover="listanchors('wo')" >listanchors(); </a >
</body> </html>