views:

26

answers:

1

I'm trying to open up a new browser window, and copy a table from the parent window into this new window. I'm using Prototype.js and this is the code I have:

prog_window = window.open();
prog_window.document.write("<html><body></body></html>");
table_clone = Element.clone('prog_table',true);
prog_window.document.addElement(table_clone);

I get an error on the third line: "TypeError: Result of expression 'Element.clone' [undefined] is not a function." I've tried a few variations for the third line, but I always get the same error. I've quadruple checked the id of the so that is not the problem. Documentation on the clone function is extremely limited, so if there is something I'm missing, could someone please point it out?

Thanks in advance, Dave

+1  A: 

Another option for you would be to do something like the following:

prog_window = window.open();
prog_window.document.write("<html><body><div id='table'></div></body></html>"
prog_window.getElementById('table').innerHTML = 
       document.getElementById('current_table').innerHTML;

There are obviously many ways to do this in JavaScript. Couple other things you could try would be to start at the parent window and call back to the "parent" window to do the cloning.

Ryan Alberts
I had to add `prog_widow.document.getElementByblahblahblah`in order to get it to work. I also had to add a lot to get the formatting right. A clone may not have had that problem.It still does not explain why the original did not work though. Anyone else know why?
the Hampster