Kor
06-16-2006, 09:54 AM
The following is rather an assumption than a question.
Trying to find a way to have an initial genuine clone ready to be appended for many times whithin the same session I have discovered that the cloneNode() method is able to clone even an object which is not part of the DOM tree (or at list I believe so). In other words cloneNode is able to clone a clone
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
var cloned
onload = function(){
cloned=document.getElementById('txt').cloneNode(true)
}
function addC(){
var clonedclone=window['cloned'].cloneNode(true)
document.getElementsByTagName('body')[0].appendChild(clonedclone)
}
</script>
</head>
<body>
<input type="button" value="ADD" onclick="addC()">
<input type="text" id="txt" value="one">
</body>
</html>
This is puzzleing me a little, as a clone (see window['cloned']) is in fact a window's object (or a function's object, if the variable is local) not a document's DOM tree object. My "academical" question is: Are my above presumptions correct? Can this be extended to other type of objects?
Trying to find a way to have an initial genuine clone ready to be appended for many times whithin the same session I have discovered that the cloneNode() method is able to clone even an object which is not part of the DOM tree (or at list I believe so). In other words cloneNode is able to clone a clone
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
var cloned
onload = function(){
cloned=document.getElementById('txt').cloneNode(true)
}
function addC(){
var clonedclone=window['cloned'].cloneNode(true)
document.getElementsByTagName('body')[0].appendChild(clonedclone)
}
</script>
</head>
<body>
<input type="button" value="ADD" onclick="addC()">
<input type="text" id="txt" value="one">
</body>
</html>
This is puzzleing me a little, as a clone (see window['cloned']) is in fact a window's object (or a function's object, if the variable is local) not a document's DOM tree object. My "academical" question is: Are my above presumptions correct? Can this be extended to other type of objects?