[thelist] Debugging JavaScript written HTML
Sarah Sweeney
mr.sanders at designshift.com
Fri Jul 23 07:41:57 CDT 2004
>>How can I look at the HTML code that my
>>script is writing
>>when only the originally loaded source is available through
>>the browser?
>
> Try this bookmarklet:
>
> javascript:var%20o=document.documentElement,p,w=window.open('','_blank'),d=w
> .document;d.write('<html><body><pre>');z('<'+o.tagName);for(var%20i=0;p=o.at
> tributes[i],i!=o.attributes.length;i++)if(p.specified)z('%20'+p.nodeName+'="
> '+p.nodeValue+'"');z('>'+o.innerHTML+'</'+o.tagName+'>');d.write('</pre></bo
> dy></html>');d.close();function%20z(s){d.write(s.replace(/&/g,'&').repla
> ce(/</g,'<').replace(/>/g,'>').replace(/"/g,'"'));}
>
> I didnt' write it. I found it somewhere (forgot where) and it's called 'Show
> Source.'
If you search Google for "view generated source bookmarklet" you'll find
a few like this, including some which will show you the source with
syntax highlighting.
--
Sarah Sweeney
Web Developer & Programmer
Portfolio :: http://sarah.designshift.com
Blog, etc :: http://hardedge.ca
More information about the thelist
mailing list