"kinne" <kinne@advalvas .be> wrote in message
news:41a8e159$0 $25071$ba620e4c @news.skynet.be ...[color=blue]
> Is it possible to pass a parameter to an external ".js" file?
>
> Kinne[/color]
Not sure exactly what you mean or want.
However, you can define a variable outside of the external ".js" file and
use it within it.
"kinne" <kinne@advalvas .be> wrote in message
news:41a8e159$0 $25071$ba620e4c @news.skynet.be ...[color=blue]
> Is it possible to pass a parameter to an external ".js" file?
>
> Kinne
>[/color]
Not sure exactly what you mean or want.
However, you can define a variable outside of the external ".js" file and
use it within it.
Thanks for replying!
My question was indeed very short, but the second part of you answer was the
kind of thing that I expected.
I need to call an external ".js" file and pass a parameter to it. This
parameter would be used in the file as a variable to perform some tests.
What I don't know is i) how to pass the variable to the code in the external
".js" file and ii) how to collect the passed variable to work with it within
the file.
The QueryString looks like to way to do this. Now that I have a starting
point, I'll try to find my way and more info about this. Thanks for giving
me the first clue.
Kinne
[...][color=blue]
> Alternatively, you could pass a parameter via the QueryString portion of[/color]
the[color=blue]
> URL:
>
> http://{domain}/{folder}/test2.htm?Hello World
>
> <html>
> <head>
> <title>test1.ht m</title>
> <script type="text/javascript" src="external.j s">
> </script>
> </head>
> <body>
> </body>
> </html>
>
> // external.js
> var parm = location.search ;
> parm = parm.substr(1);
> document.write( parm);
>
>[/color]
On Sun, 28 Nov 2004 21:41:39 +0100, kinne <kinne@advalvas .be> wrote:
[snip]
[color=blue]
> I need to call an external ".js" file and pass a parameter to it.[/color]
You cannot "call" a file; it's just plain text.
A SCRIPT element with a src attribute is effectively the same as a SCRIPT
element with the file contents included directly in it. Any script added
to a document shares the same global namespace, so the code in the second
SCRIPT element below can access the variables defined and initialised in
the first, irrespective of whether the code is stored in an external file
or included directly in the document.
<script type="text/javascript">
var someGlobal = 'A variable';
</script>
<script type="text/javascript">
alert(someGloba l); // 'A variable'
</script>
In summary, you don't need to "pass" anything.
[snip]
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
[snip][color=blue]
> You cannot "call" a file; it's just plain text.[/color]
[snip][color=blue]
> In summary, you don't need to "pass" anything.[/color]
[snip]
[color=blue][color=green]
>>[/color][/color]
OK Michael, I got it now ! Thanks for this clear answer.
Comment