Tutorial for using JavaScript on a Desktop -
I need to do some script in java script. I am working on this, but some solutions for some problems Could not find
First of all, I need a good tutorial, but not for the internet page but for a desktop script.
Things do not know like: 1) I wanted a simple message box to debug my program, I have used:
var name = prompt (" What is your name "," type name here ");
When I run it, I get an error of "expected object"
2) The way to open the file could not be found
Depending on your comments, I think that you are trying to run a javascript file directly on Windows, double-click on a .js file in windows. The click (maybe) will run in it.
The prompt ()
function will not work in this way, because WSH offers very different from browser-embedded engines.
The following code should fulfill your intentions. However, if you want anything more than a simple popup, then there is only one way to do a complex GUI with JScript on the desktop.
var fso, ws, ts; Fso = new ActiveXObject ('Scripting.FileSystemObject'); Ws = WScript.CreateObject ('WScript.Shell'); Var ForWriting = 2; Ts = fso.OpenTextFile ('foo.txt', ForWriting, true); Ts.WriteLine (new date (.) GetTime ()); Ts.Close (); Ws.Popup ('Written to File!'); Var ForReading = 1; Ts = fso.OpenTextFile ('foo.txt', ForReading, Incorrect); Var File Resource = ts.ReadLine (); Ts.Close (); Ws.Popup ('contained in file:' + filesystem); WScript.Quit ();
Comments
Post a Comment