How do I programmatically open the "View Source" window (using some Javascript) like when I right click in the browser and click "View Source"? Is this possible?
You can use the "view-source" URI schema, supported by Firefox, Chrome, and older versions of IE.
No JavaScript required, just a normal link to the page you want the user to see in source view:
<a target="_blank" href="view-source:http://www.wikipedia.org/">view Wikipedia's home page HTML source</a>
More info: