I would like to accomplish something like:
<html>
<head>
<script id="ViewSource" src="someJSfile.js"/>
<script language="javascript">
function View() {
var el=document.getElementById("ViewSource"); //works
var ta=document.getElementById("ta"); //works
ta.value=el.innerHTML; //doesn't work
}
</script>
</head>
<body>
<textarea id="ta"/>
<a href="javascript:View();">View Javascript Source Code</a>
</body>
</html>
// (please pardon any typos/errors, the above is just to illustrate what I mean)
Of course "innerHTML" doesn't work on script tags. What property/attribute can I access to view source?
I realize this can be accomplished very easily by just clicking view source in the browser. Am I crazy to hope it can be done with javascript?
Thanks in advance.