Closed
Bug 158871
Opened 22 years ago
Closed 22 years ago
Support for outerHTML
Categories
(Core :: DOM: Core & HTML, enhancement)
Core
DOM: Core & HTML
Tracking
()
People
(Reporter: erik, Assigned: jst)
Details
It would be nice to have support for the IE property outerHTML. outerHTML is
like innerHTML but it includes the HTML of the current element
Below is some rough code how to do the same thing using a dummy element and
innerHTML.
function getOuterHTML(el) {
var dummy = document.createElement("DIV");
div.appendChild(el.cloneNode(true));
return div.innerHTML
}
IE supports both read and write but I think that write is a bad idea since it
destroys the element. Take the code below for example. IE behaves really
strange here and it just does not make any sense to me.
<div>
<div id="test">monkey</div>
</div>
...
var el = document.getElementById("test");
var p = el.parentNode;
el.outerHTML; // "<DIV id=test>monkey</DIV>"
el.outerHTML = "<b>bold</b>";
el.innerHTML; // ""
el.outerHTML; // "<DIV id=test></DIV>"
p.innerHTML; // <B>bold</B>
The setter kind of makes sense from a string view of a document (IE4) but not
from a DOM view.
bug 92264 comment 4 :
"Element.outerHTML is not supported in mozilla, use element.innerHTML or the HTML
DOM, WONTFIX."
==> DUPE
*** This bug has been marked as a duplicate of 92264 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•