[Project_owners] selectNode not working as expected

Jesper Staun Hansen jesper at selvet.dk
Tue Mar 11 15:44:30 PDT 2008


Hello.

I am trying the following example (from: 
http://developer.mozilla.org/en/docs/DOM:range.insertNode):
<html>

<head>
<title>xxx</title>
</head>

<body>
<script type="text/javascript">
range = document.createRange();
newNode = document.createElement("p");
newNode.appendChild(document.createTextNode("New Node Inserted Here"));
range.selectNode(document.getElementsByTagName("div").item(0));
range.insertNode(newNode);
</script>

<div>test</div>

</body>

</html>


But i am getting this errorcode:
Error: uncaught exception: [Exception... "Parameter is not an object"  
code: "1003" nsresult: "0x805303eb (NS_ERROR_DOM_NOT_OBJECT_ERR)"  
location: "file:///location/test.html Line: 12"]
Which is this line:
range.selectNode(document.getElementsByTagName("div").item(0));

I dont get it.


Greets.



More information about the Project_owners mailing list