You can add a simple button as follows:
<button type ="button" onclick="viewSource()">View Source</button>
And then the following javascript function:
function viewSource(){;
var source = "<html>";
source += document.getElementsByTagName('html')[0].innerHTML;
source += "</html>";
source = source.replace(/</g, "<").replace(/>/g, ">");
source = "<pre>"+source+"</pre>";
sourceWindow = window.open('','Source of page','height=800,width=800,scrollbars=1,resizable=1');
sourceWindow.document.write(source);
sourceWindow.document.close();
if(window.focus) sourceWindow.focus();
}
This will open it's own window and display the source of the current page.