Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #33476 > unrolled thread

Standalone Jscript script

Started by"Dave \"Crash\" Dummy" <invalid@invalid.invalid>
First post2017-06-01 11:15 -0400
Last post2017-06-02 22:26 +0100
Articles 6 — 5 participants

Back to article view | Back to comp.lang.javascript


Contents

  Standalone Jscript script "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2017-06-01 11:15 -0400
    Re: Standalone Jscript script Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-01 16:41 +0100
    Re: Standalone Jscript script "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-06-01 17:47 +0200
      Re: Standalone Jscript script "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2017-06-01 12:02 -0400
    Re: Standalone Jscript script Martin Honnen <martin.honnen@gmx.de> - 2017-06-01 18:04 +0200
    Re: Standalone Jscript script Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-06-02 22:26 +0100

#33476 — Standalone Jscript script

From"Dave \"Crash\" Dummy" <invalid@invalid.invalid>
Date2017-06-01 11:15 -0400
SubjectStandalone Jscript script
Message-ID<ogparl$u3g$1@dont-email.me>
Although I work mostly with VBScript I have no problem writing
Javascript scripts for web pages. What I can't do is get the simplest
standalone jscript to run in Windows 10:

test.js
-----------------
alert("Hello, World!");
-----------------

I get an error for "object required."

If I try
window.alert("Hello, World!");

or
document.alert("Hello, World!");

I get a window or document undefined error. The only thing I
can get to work is a HTA workaround kluge:

test.hta
--------------
HTA:Application windowstate="minimize" showintaskbar="no">
<script type="text/jscript">
alert ("Hello, World!");
self.close();
</script>
---------------

What am I missing?

-- 
Crash

"I am not young enough to know everything."
~ Oscar Wilde ~

[toc] | [next] | [standalone]


#33477

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-06-01 16:41 +0100
Message-ID<87zidru34n.fsf@bsb.me.uk>
In reply to#33476
"Dave \"Crash\" Dummy" <invalid@invalid.invalid> writes:

> Although I work mostly with VBScript I have no problem writing
> Javascript scripts for web pages. What I can't do is get the simplest
> standalone jscript to run in Windows 10:
>
> test.js
> -----------------
> alert("Hello, World!");
> -----------------
>
> I get an error for "object required."
>
> If I try
> window.alert("Hello, World!");
>
> or
> document.alert("Hello, World!");
>
> I get a window or document undefined error. The only thing I
> can get to work is a HTA workaround kluge:
>
> test.hta
> --------------
> HTA:Application windowstate="minimize" showintaskbar="no">
> <script type="text/jscript">
> alert ("Hello, World!");
> self.close();
> </script>
> ---------------
>
> What am I missing?

Nothing.  Most standalone JS implementations won't provide an object
with an alert method.  If the HTA way works for you, then use that.  If
not, see what is provided and work with that instead.  This called the
host environment and is not part of the language itself.

For example, nodejs provides the console object that can be used to
generate simple output messages and comes with a number of libraries to
do more sophisticated things.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#33479

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2017-06-01 17:47 +0200
Message-ID<XnsA787B4FD482D9eejj99@194.109.6.166>
In reply to#33476
"Dave \"Crash\" Dummy" <invalid@invalid.invalid> wrote on 01 Jun 2017 in 
comp.lang.javascript:

> I get an error for "object required."
> 
> If I try
> window.alert("Hello, World!");
> 
> or
> document.alert("Hello, World!");

WScript.echo('hi');

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#33480

From"Dave \"Crash\" Dummy" <invalid@invalid.invalid>
Date2017-06-01 12:02 -0400
Message-ID<ogpdjh$8je$1@dont-email.me>
In reply to#33479
Evertjan. wrote:
> "Dave \"Crash\" Dummy" <invalid@invalid.invalid> wrote on 01 Jun 2017
> in comp.lang.javascript:
> 
>> I get an error for "object required."
>> 
>> If I try window.alert("Hello, World!");
>> 
>> or document.alert("Hello, World!");
> 
> WScript.echo('hi');

Thanks to you and also Stefan. I guess my problem was a poor choice of
operations. I don't really want to use "alert" for anything. It just seemed
like a simple way to build a test file using the equivalent of the
VBScript "msgbox" function. Oops...

-- 
Crash

Absence tempts the heart to wander.

[toc] | [prev] | [next] | [standalone]


#33481

FromMartin Honnen <martin.honnen@gmx.de>
Date2017-06-01 18:04 +0200
Message-ID<ogpdu7$6e7$1@news.albasani.net>
In reply to#33476
On 01.06.2017 17:15, Dave "Crash" Dummy wrote:
> Although I work mostly with VBScript I have no problem writing
> Javascript scripts for web pages. What I can't do is get the simplest
> standalone jscript to run in Windows 10:
> 
> test.js
> -----------------
> alert("Hello, World!");
> -----------------
> 
> I get an error for "object required."
> 
> If I try
> window.alert("Hello, World!");
> 
> or
> document.alert("Hello, World!");
> 
> I get a window or document undefined error. The only thing I
> can get to work is a HTA workaround kluge:
> 
> test.hta
> --------------
> HTA:Application windowstate="minimize" showintaskbar="no">
> <script type="text/jscript">
> alert ("Hello, World!");
> self.close();
> </script>
> ---------------
> 
> What am I missing?


Well, the JScript ActiveX engine you can use in Windows from the command 
line implements the ECMAScript edition 3 standard more or less, plus 
some Microsoft/Windows specific extensions to interact with VBScript. It 
is hosted in Windows Script Host when you run it from the command line: 
https://msdn.microsoft.com/en-us/library/9bbdkx3k(v=vs.84).aspx. It is 
also hosted in classic ASP pages and used to be hosted in IE until 
Microsoft decided that the old engine meant to cater for different 
environments (like IE, ASP, WSH) wasn't up to compete with the featured 
like JIT compilation introduced in the engines used in other browsers.


[toc] | [prev] | [next] | [standalone]


#33496

FromDr J R Stockton <reply1700@merlyn.demon.co.uk.invalid>
Date2017-06-02 22:26 +0100
Message-ID<Fvoo+xN+fdMZFwNY@invalid.uk.co.demon.merlyn.invalid>
In reply to#33476
In comp.lang.javascript message <ogparl$u3g$1@dont-email.me>, Thu, 1 Jun
2017 11:15:19, "Dave \"Crash\" Dummy" <invalid@invalid.invalid> posted:

>What am I missing?

Possibly, command-line / batch file constructions such as

      Call cscript //nologo PRE-PROC.JS $$$TRIAL.HTM $$$TRIAL.1.HTM
::                          JavaScript      Arg 1        Arg 2
:: &
      Call wscript .....


-- 
 (c) John Stockton, Surrey, UK.  ¬@merlyn.demon.co.uk   Turnpike v6.05   MIME.
 Merlyn Web Site <                       > - FAQish topics, acronyms, & links.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web