/ Published in: JavaScript

This is a little trick I came up with to add outerHTML functionality in Firefox. For those who aren't familiar with outerHTML, it is an IE addition to the DOM that will return the element's HTML PLUS it's innerHTML. Is it really needed? No, but it can help with debugging sometimes.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
if (document.body.__defineGetter__) { if (HTMLElement) { var element = HTMLElement.prototype; if (element.__defineGetter__) { element.__defineGetter__("outerHTML", function () { var parent = this.parentNode; var el = document.createElement(parent.tagName); el.appendChild(this); var shtml = el.innerHTML; parent.appendChild(this); return shtml; } ); } } }
URL: http://www.mohundro.com/blog/CommentView,guid,469f80ae-968d-4d60-ab5b-62a06bf045c5.aspx
Comments
