hi all,
any dom experts out there. i'm trying to use removeChild, appendChild and insertBefore to implement a cut-n-paste routine. everything works great in ie, but ns6 is not cooperating. looking for some guidance.
specifically, i can't get the insertBefore method to work properly in ns6. my test page for this follows...
any ideas???
also, it appears that ns6 creates a text type child node for each tag, so that even if a tag doesn't have a specified child tag, ns6 will report a child node of type text. ie, on the other hand, only reports a child node where you have specifically created one. any ideas on why this is? any comments on the implications of this when working with nodes in ns6?
thanks,
glenn
any dom experts out there. i'm trying to use removeChild, appendChild and insertBefore to implement a cut-n-paste routine. everything works great in ie, but ns6 is not cooperating. looking for some guidance.
specifically, i can't get the insertBefore method to work properly in ns6. my test page for this follows...
Code:
<html><head><title>DOM Test</title>
<style type="text/css">
<!--
.clsBox {
width: 50;
height: 50;
margin-bottom: 10;
}
.clsClipBoard {
position: absolute;
right: 10;
top: 10;
border-width: 2;
border-style: solid;
width: 60;
height: 60;
}
.clsColumn {
position: absolute;
top: 100;
}
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function change(obj) {
var clipBoard = document.getElementById("clipBoard");
var delNode;
if (!clipBoard.hasChildNodes()) {
if (confirm("Cut Section?")==true) {
var delNode = obj.parentNode.removeChild(obj);
clipBoard.appendChild(delNode);
}
}
else {
if (confirm("Paste From ClipBoard")==true) {
if (obj.nextSibling == null || (obj.nextSibling.nodeType==3 && obj.nextSibling.nextSibling==null)) {
if (confirm("Click 'Yes' to paste above. Click 'Cancel' to paste below.")==false) {
obj.parentNode.appendChild(clipBoard.firstChild); //this works fine in ns6
}
else {
obj.parentNode.insertBefore(clipBoard.firstChild,obj); //this doesn't work in ns6
}
}
else {
obj.parentNode.insertBefore(clipBoard.firstChild,obj); //this doesn't work in ns6
}
}
}
}
//-->
</script></head><body>
<div id="column1" class="clsColumn" style="left: 100">
<div id="box1" class="clsBox" style="background-color:orange" onclick="change(this)"></div>
<div id="box2" class="clsBox" style="background-color:pink" onclick="change(this)"></div>
<div id="box3" class="clsBox" style="background-color:green" onclick="change(this)"></div>
</div>
<div id="column2" class="clsColumn" style="left: 200">
<div id="box4" class="clsBox" style="background-color:purple" onclick="change(this)"><span>Text</span></div>
<div id="box5" class="clsBox" style="background-color:yellow" onclick="change(this)"><span>Text</span></div>
<div id="box6" class="clsBox" style="background-color:red" onclick="change(this)"><span>Text</span></div>
</div>
<div id="clipBoard" class="clsClipBoard"></div></body></html>
any ideas???
also, it appears that ns6 creates a text type child node for each tag, so that even if a tag doesn't have a specified child tag, ns6 will report a child node of type text. ie, on the other hand, only reports a child node where you have specifically created one. any ideas on why this is? any comments on the implications of this when working with nodes in ns6?
thanks,
glenn