I want to use *.js file both: on local web page on my pc (as JavaScript) and as WSH JScript when I double click *.js file. Is it possible to write a code running on both platforms?
How to check is running JS file is JavaScript or Microsoft JScript?
I tried this, but it doesn't work:
if (typeof(document) == "undefined")
alert('WSH Script!');
WScript.Quit;
}
else {
document.writeln('Hello world');
}
You can check if WScript
object exists e.g
if (typeof WScript === 'object')
Quit
is a function so you should call it, e.g
WScript.Quit();