Skip to content

Instantly share code, notes, and snippets.

@satyr
Created April 27, 2010 08:41
Show Gist options
  • Save satyr/380504 to your computer and use it in GitHub Desktop.
Save satyr/380504 to your computer and use it in GitHub Desktop.
outerHTML
<script>
HTMLElement.prototype.__defineGetter__('outerHTML', function(){
var _ = this.ownerDocument.createElement('_');
_.appendChild(this.cloneNode(true));
return _.innerHTML;
});
HTMLElement.prototype.__defineSetter__('outerHTML', function(h){
var r = this.ownerDocument.createRange();
r.selectNode(this);
this.parentNode.replaceChild(r.createContextualFragment(h), this);
});
function onload(){
document.body.outerHTML =
'<xmp>' + document.querySelector('script').outerHTML;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment