I'm a javascript novice trying to write a client-side program that
needs to examine the text of some included code.
Suppose you have the following snippet in an html document:
<script id="included" src="inc.js" type="text/javascript"></script>
I want to be able to write a function along the following lines:
function inspect() {
var s = document.findBy ElementId("incl uded");
var includedCodeAsS tring = ... ; //<------- s.nodeValue,
s.innerHTML???
//analyze includedCodeAsS tring
}
That is, I want to be able to access the file inc.js which should be
have been downloaded by the browser. I've tried things like s.innerHTML
without luck.
My current solution to this is to use AJAX (XMLHttpRequest ) to GET
inc.js from the server ... but this feels wrong.
Thanks for any help you can provide.
-Nik
needs to examine the text of some included code.
Suppose you have the following snippet in an html document:
<script id="included" src="inc.js" type="text/javascript"></script>
I want to be able to write a function along the following lines:
function inspect() {
var s = document.findBy ElementId("incl uded");
var includedCodeAsS tring = ... ; //<------- s.nodeValue,
s.innerHTML???
//analyze includedCodeAsS tring
}
That is, I want to be able to access the file inc.js which should be
have been downloaded by the browser. I've tried things like s.innerHTML
without luck.
My current solution to this is to use AJAX (XMLHttpRequest ) to GET
inc.js from the server ... but this feels wrong.
Thanks for any help you can provide.
-Nik
Comment