Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Standalone Jscript script Date: Thu, 01 Jun 2017 16:41:28 +0100 Organization: A noiseless patient Spider Lines: 44 Message-ID: <87zidru34n.fsf@bsb.me.uk> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b8cfcc8b3b6248419b3e2a0831823cf6"; logging-data="29728"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194mryl4jnFNhC1PAFOFqZ6nnfFL6ObKsE=" Cancel-Lock: sha1:EYHCCoBB5021CfVbPju4h7uFe3Y= sha1:Xs2Zxk+Pzsvot/c4CWQG2JQx0Vc= X-BSB-Auth: 1.cb9855b2366c6569769f.20170601164128BST.87zidru34n.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:33477 "Dave \"Crash\" Dummy" 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"> > > --------------- > > 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.