By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

Can't Open .js File w/ Script Host Error

P: n/a
Hello.

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.

I seem to be having a 'windows' problem w/ Window Script Host. While this is
more of a computer support based problem, I was hoping that someone had any
knowledge on how to resolve this situation. The error message I'm getting is:
Line: 5
Char: 1
Error: 'document' is undefined
Code: 800A1391
Source: Microsoft JScript Runtime Error

Is there any idea on how to resolve this?

--
Message posted via http://www.webmasterkb.com

Aug 10 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"LayneMitch via WebmasterKB.com" <u39402@uwewrote in
news:88792a5bc9408@uwe:

message I'm getting is:
Line: 5
Char: 1
Error: 'document' is undefined
Code: 800A1391
Source: Microsoft JScript Runtime Error

Is there any idea on how to resolve this?
It seems vaguely familiar. I am sure it is one of those simple errors where
you end up batting the side of your head after you find the problem.

Clear all your cache, make sure that file names are consistent regarding
case if your server is not Windows-based, and then see if you get the same
error using firefox. Chances are, the FF error console will give you a much
more meaningful message.

You might also give us the link so that we can look at it ourselves. (i.e.
do not put the code here, put it into an isolated area on your server or
even a dedicated server.
Aug 11 '08 #2

P: n/a
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
Aug 13 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.