outerHTML not working in FireFox

J

John Kotuby

Hello all,
Maybe there is a better place to post this, but I'm not sure where.
I am writing a Web application. Using a pop-up for printing a portion of the
parent window, from an imbedded javascript function, I am using OuterHtml to
grab that markup and then place it in the markup of the page displaying in
the pop-up.
Here is the script...

function setMyContent()
{
var theBody =
window.opener.document.getElementById("cardContent").outerHTML;
var theDivTag = document.getElementById("theCard");
theDivTag.innerHTML = theBody;
}
</script>

This all works fine in IE6 and IE7, but I am getting "undefined" returned in
Firefox.

Anyone know?

Thanks to all...
 
M

Martin Honnen

John said:
function setMyContent()
{
var theBody =
window.opener.document.getElementById("cardContent").outerHTML;
var theDivTag = document.getElementById("theCard");
theDivTag.innerHTML = theBody;
}
</script>

This all works fine in IE6 and IE7, but I am getting "undefined" returned in
Firefox.

Firefox does not support outerHTML.

If all you want to do is clone the contents of an element in one window
to an element in another window then with Firefox you can use the DOM
importNode method e.g.
if (typeof document.importNode != 'undefined') {
var element = window.opener.document.getElementById("cardContent");
var clone = document.importNode(element, true);
document.getElementById("theCard").appendChild(clone);
}

IE does not support importNode so for IE you need to continue to use the
outer/innerHTML approach.
 
J

John Kotuby

Martin..

Thank you VERY much for the syntax. What a great help that is!
.... John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top