Skip to content

Instantly share code, notes, and snippets.

@dmachi
Created July 7, 2010 02:14
Show Gist options
  • Select an option

  • Save dmachi/466209 to your computer and use it in GitHub Desktop.

Select an option

Save dmachi/466209 to your computer and use it in GitHub Desktop.
javascript:(function(){function serializer(rootNode){if(!rootNode){throw new Error("Node to serialize required");}if (rootNode.nodeType==3){this.text=rootNode.nodeValue}else if(rootNode.tagName=="SCRIPT"||!rootNode.tagName){}else{this.tagName=rootNode.tagName;if(rootNode.style){ this.style=(rootNode.style.cssText+"").toLowerCase();}this.attributes={};dojo.forEach(rootNode.attributes,function(attr){if(attr.nodeValue){this.attributes[attr.nodeName]=attr.nodeValue;}},this);this.children=[];dojo.forEach(rootNode.childNodes,function(node){this.children.push(new serializer(node));},this);}}var obj = new serializer(dojo.body());var notice=document.createElement("div");dojo.style(notice,{left:0,top:0,height:"200px",width:"450px",position:"absolute",overflow:"auto",zIndex:1000,background:"#fff",border:"2px solid green"});notice.innerHTML=dojo.toJson(obj);document.body.appendChild(notice);dojo.connect(dojo.body(),"onkeydown",function(e){if(e.keyCode=='68'){dojo.destroy(notice)}})})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment