LayneMitch via WebmasterKB.com wrote:
>
I posted this earlier with the full code of the JavaScript file I'm trying to
open. I'm posting this again, because the file is not the problem.
The problem is what you're doing with the file.
I seem to be having a 'windows' problem w/ Window Script Host.
I wouldn't call it a "'windows' problem" (which I assume means "a
problem with the Windows operating system"). The problem is that
you're using Windows (not "Window") Script Host to try to execute
ECMAScript code that's written for a different environment (a browser).
You have downloaded some ECMAScript and saved it as a file, with the
".js" extension. (Apparently "typedcore.js", based on your previous
thread.) The default handler for that extension in your copy of
Windows is very likely one of the WSH launchers (probably
wscript.exe). That means if you ask Windows to execute "typedcore.js"
- from a command prompt, for example - Windows will run wscript.exe
with "typedcore.js" as a command-line argument.
WSH has an ECMAScript engine - Microsoft's JScript. That lets you run
ECMAScript programs under WSH: you can use ECMAScript as a Windows
scripting language, in other words. The WSH JScript engine has various
extensions that allow you to manipulate Windows OS objects. What it
does not have, since it is not running in a browser, is the HTML DOM.
Thus it will not run typical ECMAScript functions written to run in a
browser window, because they generally want to operate on the DOM.
If you see a WSH error, you're asking Windows to execute your
ECMAScript under WSH. Don't do that, unless you're trying to learn WSH
scripting with JScript.
If you want to experiment with ECMAScript on web pages (the
environment where the vast majority of it is used), you need to have a
browser load typedcore.js as a script. That generally means including
it in an HTML document, either inline or as a URI reference, using a
SCRIPT element.
(There are alternatives, such as the "JavaScript Shell" that's
available for Firefox, which provides a command for loading ECMAScript
interactively. But we'll stick with the common case here.)
So what you need is an HTML page with a SCRIPT element that has the
value of its SRC attribute set to a *valid URL* for your ECMAScript
source file. You posted some HTML source in the other thread that
almost accomplished that, but it had an invalid URL for the script
source. (It wasn't great HTML - no DOCTYPE, for example, and I'd put
*some* content in the body so that you can be sure you're loading what
you think you're loading - but it should do.)
So fix the value of that SRC attribute. David Mark already gave you
the best suggestion: put typedcore.js in the same directory as the
HTML file, and use just "typedcore.js" as the URL. Then open the HTML
file in your browser.
--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University