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...
 
G

Guest

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...

try to use this function

function getOuterHTML(object) {
var element;
if (!object) return null;
element = document.createElement("div");
element.appendChild(object.cloneNode(true));
return element.innerHTML;
}
 
M

Mark Rae

I am using outerHTML

According to Danny Goodman's "Dynamic HTML - The Definitive Reference",
outerHTML is supported in IE 4 and above, Safari 1.3 and above, and Opera 7
and above.

It is not supported in Netscape or Mozilla (i.e. FireFox)...
 
J

John Kotuby

Thanks Alexey...

Anon User said:
try to use this function

function getOuterHTML(object) {
var element;
if (!object) return null;
element = document.createElement("div");
element.appendChild(object.cloneNode(true));
return element.innerHTML;
}
 
B

bruce barker

outerHTML is not a valid W3C dom property so is not supported by
firefox. firefox does support innerHTML even though its not a standard.

you should be using W3C properties like nodeValue (for innerHTML). you
can use the document.createNode() to clone the outernode (be sure to
copy attributes)

-- bruce (sqlwork.com)
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top