Before software can be reusable it first has to be usable.
Ralph Johnson

View the Current Page’s Current Source Code

Do you know that when you choose to “View Source” in your browser (Ctrl+U in Firefox). You will see the page source as it is delivered by the server. Any change made by the client-side script will not be seen. So, how do we see the current page CURRENT source code? I have been using Firebug for this, but just now I see somebody post the JavaScript code for this in kaskus (Largest Indonesian Community).

Here is the code he use:

javascript:h=document.getElementsByTagName('html')[0].innerHTML;function%20disp(h){h=h.replace(/</g,'\n&lt;');h=h.replace(/>/g,'&gt;');document.getElementsByTagName('body')[0].innerHTML='<pre>&lt;html&gt;'+h.replace(/(\n|\r)+/g,'\n')+'&lt;/html&gt;</pre>';}void(disp(h));

At a quick glance, this script will replace all “<” with “&lt;” and all “>” with “&gt;” inside the “<html>” tag thus removing all tags and make those tags readable.

Let’s break down the code: Read the rest of this entry »

February 22nd, 2011 JavaScript Tags: , , , 0 Comment 815 views