Apr 7th, 2008 23:17
ha mo, Jean-Bernard Valentaten, James Currie, Colin Fraser, sushil Pan,
I am going to assume you mean the DOS command line in pre- XP Windows or
Firstly, why would you want to?
the browser, not outside it. (Someone may actually argue this, but I bet
users and writers.)
to be used in the manner you are thinking.
First: I can think of many reasons, even in an XP envrionment. Do not
JS was not invented by MS and was not inteneded to be a MS specific
language. In fact it was intended to be platform independent. JS is
used in Windows through WSH or Windows Scripting Host, and can be
executed from a command prompt simply by typing the name of the file
Second: Yes it can be done. just like any other executable, any
paramaters after the file name are passed to the script.
c:\>example.js par1 test
in the case above par1 and test are parameters. In your script access
this parameter with the following code:
var param1 = WScript.Arguments.Item(0);
var param2 = WScript.Arguments.Item(1);
Some good examples of uses:
Writing an XML parser that is passed the name of the file to parse
using a command line parameter.
Integrating with a 3rd party application that will execute outside
applications and pass variables through parameters.
Well, now we can all calm down a little and try to focus on the
question, which was meant as "How do I pass an argument from a
since it's purpose was (and still is) to access a DOM inside a browser
(and have limited access to the browser itself).
It is true that Microsoft introduced a WSH-Engine that interpretes a
MS Windows (ok, there are engines for MacOS and a couple of unices *g*)
So, if one wants access to the system, hear my advice: learn to code a
serverside scripting language (ASP, JSP, PHP ...) in case you wish to
call external programs on the server or use a Java applet if this has
to be done clientside.
Well, one might also use JScript, but only if you are absolutely sure
that you'll only have Windows based clients on your site :)