Click to See Complete Forum and Search --> : cloneNode appendChild in IE


p.phresh
06-27-2007, 03:27 PM
I've coded a pop up window that's supposed to take the information from one page and clone it into the new pop up window.

The information to be cloned is a table and does not come from the pop up parent, but is open in a frame in a sibling.

Can cloneNode transport information from one window to another in IE? It works perfectly in FF.

here's the bit of code i'm using:


var generator = window.open('','printPop','height=600,width=700,top=0,scrollbars=yes,status=yes');

var f_head = parent.head.document;
var f_ipl = parent.ipl.document;

var head_table = f_head.getElementById('header');
var head_clone = head_table.cloneNode(true);

var newDiv = generator.document.createElement("div");
newDiv.setAttribute("id", "newDiv");
var divTags = generator.document.getElementsByTagName("div");
var thisDiv = divTags[0];
thisDiv.appendChild(newDiv);
newDiv.appendChild(head_clone);


Is this the right way to do it for IE? Is there another method so it can work in IE?

I've tried the innerHTML method, it copies the text only and leaves all the Table tags behind, and i would rather not use it if i can choose.

thanks for any help anyone can provide.

Logic Ali
06-27-2007, 09:39 PM
Are you quite sure there's nothing showing in I.E.'s error console?
I would expect an 'interface not supported' error.
It seems that I.E. will not attach any element (cloned or not) created in another window. In the simplified example below, the commented alternatives won't work, but are OK with FX and Opera 9.
I haven't Googled this issue as yet.

<body>
<form>
<input type='button' onclick='buildWin()' value='GO'>
</form>
<div id='cloneMe'>
Original
</div>

<script type='text/javascript'>
function buildWin()
{
var generator = window.open('','printPop','height=600,width=700,top=0,scrollbars=yes,status=yes');

generator.newDiv = generator.document.createElement("div");
//generator.newDiv = document.createElement("div"); /*Not with I.E.*/
//generator.newDiv = document.getElementById('cloneMe').cloneNode(true); /*Not with I.E.*/

generator.newDiv.appendChild(generator.document.createTextNode("- New text"));
generator.document.body.appendChild(generator.newDiv)
}
</script>
</body>

p.phresh
06-28-2007, 08:08 AM
i'm not getting any errors at all.

and the window is blank where the table should be displayed.

Fang
06-28-2007, 08:45 AM
Try using the all collection (http://msdn2.microsoft.com/en-us/library/ms536365.aspx) as in the example