首页 新闻 会员 周边 捐助

js NodeFilter运行不了

0
[已关闭问题] 关闭于 2012-03-29 13:40

程序运行到红色部分就出错,提示说NodeFilter未定义,求指教????

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
//NodeIterator
var iterator = null;
function makeList(){
 var oDiv = document.getElementById("div1");
 var oFilter = new Object;
 oFilter.acceptNode = function(oNode){
  return (oNode.tagName == "p") ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
 };
 iterator = document.createNodeIterator(oDiv, NodeFilter.SHOW_ELEMENT, oFilter, false);   

 var oOutput = document.getElementById("text1");
 var oNode = iterator.nextNode();
 while(oNode){
  oOutput.value += oNode.tagName + "\n";
  oNode = iterator.nextNode();
 }
}
</script>
</head>

<body>
<div >
 <p align="left">hello <b>world!</b></p>
 <ul>
     <li>List item1</li>
        <li>List item2</li>
        <li>List item3</li>
    </ul>
</div>
<textarea rows="10" cols="40"></textarea><br />
<input type="button" name="testBtn" value="测试" onclick="makeList()"/>
</body>
</html>

虎犊求知的主页 虎犊求知 | 初学一级 | 园豆:122
提问于:2012-03-29 13:37
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册