Re: all script functions
- From: "Julian Turner" <julian@xxxxxxxxxxxxxx>
- Date: 27 Feb 2006 07:34:49 -0800
Praveen wrote:
[snip]
But still Im not able to get the text of included .js files.[/snip]
Here is the sample which I tried.
I want to get the contents of the included Test.js file.
<HTML>
<HEAD>
<script language = javascript src=Test.js></script>
</HEAD>
<script>
function F(){
//Im able to get this right
alert(document.scripts.item(1).text)
//this is coming as blank
alert(document.scripts.item(0).text)
}
</script>
I suspect this is because the browser does count the linked file as
"text" for the purposes of the text property. I.e. the text property
retrieves text between the script tags <script>// Text Here</script>.
Or perhaps "Test.js" does not exist in the same domain and folder as
your web page. I.e. "Test.js" is a relative URL, is it pointing to the
right place?
Why do you need to get the text of the script if it is your own script
in the first place?
Alternatives to consider are:-
(a) If it is a local file on your computer, use the ActiveXObject
"Scripting.FileSystemObject".
(b) If it is a remote file, use an HTTPRequest object, and get the
script as a String through the "responseText" property.
Regards
Julian Turner
.
- References:
- all script functions
- From: Praveen
- Re: all script functions
- From: Daniel Kirsch
- Re: all script functions
- From: Praveen
- all script functions
- Prev by Date: Re: all script functions
- Next by Date: Re: "?" in XMLHttpRequest.ResponseText
- Previous by thread: Re: all script functions
- Next by thread: Re: all script functions
- Index(es):
Relevant Pages
|