有关JS的NodeIterator
<html>
<head>
<script type= "text/javascript ">
var iterator=null;
function makeList(){
var oDiv=document.getElementById( "div1 ");
iterator=document.createNodeIterator(oDiv,NodeFilter.SHOW_ELEMENT,null,false);
varoOutput=document.getElementById( "text1 ");
var oNode=iterator.nextNode();
while(oNode) {
oOutput.value+=oNode.tagName+ "\n ";
oNode=iterator.nextNode();
}
}
</script>
</head>
<body>
<div id= "div1 ">
<p> hello <b> world! </b> </p>
<ul>
<li> List item1 </li>
<li> List item1 </li>
<li> List item1 </li>
</ul>
</div>
<textarea rows= "10 " cols= "40 " id= "text1 "> </textarea> <br />
<input type= "button " value= "Make List " onclick= "makeList() " />
</body>
</html>
打开网页点击按钮,总说第11行NodeFilter未定义。请高手帮忙
------解决方案--------------------要在firefox下测试,IE不支持这样的写法。
------解决方案--------------------这是DOM Level2的功能,只有在Mozilla和Konqueror/Safari中才有。