473,856 Members | 1,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Runtime Error...Can't Figure Out Why...

Hello.

This is a reference file from a book I read in which the core subject is the
use of 'event listeners'.

I'm trying to load the file in Firefox and it's giving me an error message:

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

I need this file to work because it's the reference file for all of my coding.
Here's the contents of the file here.

var Core={};

// W3C DOM 2 Events model

if (document.addEv entListener)
{
Core.addEventLi stener = function(target , type, listener)
{
target.addEvent Listener (type, listener, false);
};
Core.removeEven tListener = function(target , type, listener)
{
target.removeEv entListener(typ e, listener, false);
};

Core.preventDef ault = function(event)
{
event.preventDe fault();
};

Core.stopPropag ation = function(event)
{
event.stopPropa gation();
};
}

// Internet Explorer Events model

else if (document.attac hEvent)
{
Core.addEventLi stener = function(target , type, listener)
{
// prevent adding the same listener twice, since DOM 2

// Events ignores duplicates like this

if (Core._findList ener(target, type, listener) != -1)
return;

// listener2 calls listener as a method of target in one of

// two ways, depending on what this version of IE supports,

// and passes it the global event object as an argument

var listener2 = function()
{
var event = window.event;

if (Function.proto type.call)
{
listener.call(t arget, event);
}

else
{
target._current Listener = listener;
target._current Listener(event)
target._current Listener = null;
}
};
// add listener2 using IE's attachEvent method
target.attachEv ent("on" + type, listener2);

// create an object describing this listener so we can

// clean it up later

var listenerRecord =
{
target: target,
type: type,
listener: listener,
listener2: listener2
};

// get a reference to the window object containing target

var targetDocument = target.document || target;
var targetWindow = targetDocument. parentWindow;

// create a unique ID for this listener

var listenerId = "1" + Core._listenerC ounter++;

// store a record of this listener in the window object

if (!targetWindow. _allListeners)
targetWindow._a llListeners = {};
targetWindow._a llListeners[listenerID] = listenerRecord;

// store this listener's ID in target

if (!target._liste ners) target._listene rs = [];
target._listene rs[target._listene rs.length] = listenerId;

// set up Core._removeAll Listeners to clean up all

// listeners on unload

if (!targetWindow. _unloadListener Added)
{
targetWindow._u nloadListenerAd ded = true;
targetWindow.at tachEvent(
"onunload", Core._removeAll Listeners);
}
};
Core.removeEven tListener = function(target , type, listener)
{
// find out if the listener was actually added to target

var listenerIndex = Core._findListe ner(
target, type, listener);
if (listenerIndex == -1) return;

// get a reference to the window object containing target

var targetDocument = target.document || target;
var targetWindow = targetDocument. parentWindow;

// obtain the record of the listener from the window object

var listenerId = target._listene rs[listenerIndex];
var listenerRecord =
targetWindow._a llListeners[listenerId];

// remove the listener, and remove its ID from target

target.detachEv ent("on" + type, listenerRecord. listener2);
target._listene rs.splice(liste nerIndex, 1);

// remove the record of the listener from the window object

delete targetWindow._a llListeners[listenerId];

};

Core.preventDef ault = function(event)
{
event.returnVal ue = false;
};

Core.stopPropag ation = function(event)
{
event.cancelBub ble = true;
};

Core._findListe ner = function(target , type, listener)
{
// get the array of listener IDs added to target

var listeners = target._listene rs;
if (!listeners) return -1;

// get a reference to the window object containing target

var targetDocument = target.document || target;
var targetWindow = targetDocument. parentWindow;

// searching backward (to speed up onunload processing),

// find the listener

for (var i = listeners.lengt h - 1; i >= 0; i--)
{
// get the listener's ID from target

var listenerId = listeners[i];

// get the record of the listener from the window object

var listenerRecord =
targetWindow._a llListeners[listenerId];

// compare type and listener with the retrieved record

if (listenerRecord .type == type &&
listenerRecord. listener == listener)
{
return i;
}
}
return -1;
};

Core._removeAll Listeners = function()
{
var targetWindow = this;

for (id in targetWindow._a llListeners)
{
var listenerRecord = targetWindow._a llListeners[id];
listenerRecord. target.detachEv ent(
"on" + listenerRecord. type, listenerRecord. listener2);
delete targetWindow._a llListeners[id];
}
};

Core._listenerC ounter = 0;

}
Core.addClass = function(target , theClass)
{
if (!Core.hasClass (target, theClass))
{
if (target.classNa me == " ")
{
target.classNam e = theClass;
}

else
{
target.classNam e += " " + theClass;
}
}

};
Core.getElement sByClass = function(theCla ss)
{
var elementArray = [];

if (typeof document.all != "undefined" )
{
elementArray = document.all;
}

else
{
elementArray = document.getEle mentsByTagName( "*");
}

var matchedArray = [];
var pattern = new RegExp("(^| )" + theClass + "( |$)");

for (var i = 0; i < elementArray.le ngth; i++)
{
if (pattern.test(e lementArray[i].className))
{
matchedArray[matchedArray.le ngth] = elementArray[i];
}
}

return matchedArray;

};
Core.hasClass = function(target , theClass)
{
var pattern = new RegExp("(^| )" + theClass + "( |$)");

if (pattern.test(t arget.className ))
{
return true;
}

return false;

};
Core.removeClas s = function(target , theClass)
{
var pattern = new RegExp("(^| )" + theClass + "( |$)");

target.classNam e = target.classNam e.replace(patte rn, "$1");
target.classNam e = target.classNam e.replace(/ $/, " ");
};
Core.getCompute dStyle = function(elemen t, styleProperty)
{
var computedStyle = null;

if (typeof element.current Style != "undefined" )
{
computedStyle = element.current Style;
}

else
{
computedStyle =
document.defaul tView.getComput edStyle(element , null);
}

return computedStyle[styleProperty];

};

Core.start = function(runnab le)
{
Core.addEventLi stener(window, "load", runnable.init);
};

--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forum...cript/200808/1

Aug 10 '08 #1
11 2854
LayneMitch via WebmasterKB.com wrote:
Hello.

This is a reference file from a book I read in which the core subject is the
use of 'event listeners'.

I'm trying to load the file in Firefox and it's giving me an error message:

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

Are you sure this Error came from Firefox?
Aug 10 '08 #2
dhtml wrote:
>Hello.
[quoted text clipped - 8 lines]
>Code: 800A1391
Source: Microsoft JScript Runtime Error

Are you sure this Error came from Firefox?
Positive.

It's coming from firefox and IE. It's an extremely strange situation because
the code is taken straight from the book. Also, I downloaded the code from
the publisher's site (www.sitepoint.com), and it's giving me the same error
for the code downloaded from the site.

--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forum...cript/200808/1

Aug 10 '08 #3
LayneMitch via WebmasterKB.com wrote:
dhtml wrote:
>[quoted text clipped - 8 lines]
>>Code: 800A1391
Source: Microsoft JScript Runtime Error
Are you sure this Error came from Firefox?

Positive.

It's coming from firefox and IE.
It cannot come *from Firefox* (i.e. Gecko) because Gecko does not implement
Microsoft JScript; it implements Netscape/Mozilla.org JavaScript instead:

<http://PointedEars.de/es-matrix>

This suggests instead that the cause is server-side JScript in ASP (.NET);
HTML user agents would only display what the server has responded with (cf.
"404 File Not Found"). Very likely other browsers (like Opera) would
display the same error message, unless you have resorted to browser sniffing
server-side and that is what is borken here.

Google is your friend. [psf 6.1]
It's an extremely strange situation because the code is taken straight
from the book. Also, I downloaded the code from the publisher's site
(www.sitepoint.com), and it's giving me the same error for the code
downloaded from the site.
It would seem you lack the minimum clue for what you are doing, which does
not bode well for your successfully implementing this code. RTFM, STFW, RTFFAQ.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 10 '08 #4
Thomas 'PointedEars' Lahn wrote:
>It cannot come *from Firefox* (i.e. Gecko) because Gecko does not implement
Microsoft JScript; it implements Netscape/Mozilla.org JavaScript instead:
It would seem you lack the minimum clue for what you are doing, which does
not bode well for your successfully implementing this code. RTFM, STFW, RTFFAQ.
And you are right to a certain extent. I am an amateur at coding. I expected
the js files to automatically open with no complications. I have researched a
little (yahoo instead of google), and found that this error isn't being
caused by firefox or IE...it's a Windows problem. If you have any further
suggestions on how to troubleshoot this, it would be much appreciated.

--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forum...cript/200808/1

Aug 10 '08 #5
In article <8870dad7cf8bb@ uwe>, "LayneMitch via WebmasterKB.com " <u39402@uwewrot e:
>dhtml wrote:
>>Hello.
[quoted text clipped - 8 lines]
>>Code: 800A1391
Source: Microsoft JScript Runtime Error

Are you sure this Error came from Firefox?

Positive.
Impossible.

--
Regards,
Doug Miller (alphageek-at-milmac-dot-com)

Join the UseNet Improvement Project: killfile Google Groups.
http://www.improve-usenet.org

Get a copy of my NEW AND IMPROVED TrollFilter for NewsProxy/Nfilter
by sending email to autoresponder at filterinfo-at-milmac-dot-com
You must use your REAL email address to get a response.

Download Nfilter at http://www.milmac.com/np-120.exe

Aug 10 '08 #6
Doug Miller wrote:
>>>Hello.
[quoted text clipped - 5 lines]
>>
Positive.

Impossible.
I think that if you would read the last post, you can see that I understand
that this isn't Firefox or IE issue.

--
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forum...cript/200808/1

Aug 10 '08 #7
On Aug 10, 3:03*pm, "LayneMitch via WebmasterKB.com " <u39402@uwe>
wrote:
Doug Miller wrote:
>>Hello.
[quoted text clipped - 5 lines]
>Positive.
Impossible.

I think that if you would read the last post, you can see that I understand
that this isn't Firefox or IE issue.
I read all of your posts in this thread. You don't understand
anything. It sounds to me like you are downloading the file and
opening it with the shell (of course document is undefined!)
Aug 10 '08 #8
David Mark wrote:
>I read all of your posts in this thread. You don't understand
anything. It sounds to me like you are downloading the file and
opening it with the shell (of course document is undefined!)
Okay...

no...I'm not 100% efficient on the use of JavaScript reference files. I'm 5
mths into the language. However, I do know how to write JavaScript code. I've
just completed my reading material and I'm ready to begin practicing a list
of programming examples I've come up with for myself. The problem I'm having
is the setup.

I saved the .js file to my hard-drive. I worked on one of the problems I have
and referenced the .js file. I then save the script as a .html, clicked on it
and nothing happened. I then tried to see if there was something wrong with
the .js file itself by using Firefox Debugger. This is when I received the
error, and thus thought that this is the reason why my script isn't running.

You're saying I'm "opening it with the shell" what does that mean and what
significance does it have toward this process?

Here is my small program:

<html><head><ti tle>Prob.1</title>
<script type="text/javascript" src="C:/typedcore.js"></script>
<script type="text/javascript">

var Nameprompt=
{
init:function()
{
var name=prompt("Wh at's your name," "");
Nameprompt.disp lay(name);
},

display:functio n(this)
{
document.write( "Welcome"+this+ "to the wonders of JavaScript");
}
};
Core.start(Name prompt)
</script>
</head>
<body></body>
</html>

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

Aug 10 '08 #9
On Aug 10, 3:40*pm, "LayneMitch via WebmasterKB.com " <u39402@uwe>
wrote:
David Mark wrote:
I read all of your posts in this thread. *You don't understand
anything. *It sounds to me like you are downloading the file and
opening it with the shell (of course document is undefined!)

Okay...
[snip]
I saved the .js file to my hard-drive. I worked on one of the problems I have
and referenced the .js file. I then save the script as a .html, clicked on it
Saved the script as HTML?
and nothing happened. I then tried to see if there was something wrong with
the .js file itself by using Firefox Debugger. This is when I received the
error, and thus thought that this is the reason why my script isn't running.

You're saying I'm "opening it with the shell" what does that mean and what
significance does it have toward this process?

Here is my small program:

<html><head><ti tle>Prob.1</title>
<script type="text/javascript" src="C:/typedcore.js"></script>
That isn't a correct file URI. Why not place the JS file in the same
folder as this document and use "typedcore. js" for the src attribute?
<script type="text/javascript">

var Nameprompt=
*{
* *init:function( )
* *{
* * *var name=prompt("Wh at's your name," "");
* * *Nameprompt.dis play(name);
* *},

* *display:functi on(this)
* *{
* * document.write( "Welcome"+this+ "to the wonders of JavaScript");
* *}
*};

Core.start(Name prompt)
</script>
</head>
<body></body>
</html>

--
Message posted viahttp://www.webmasterkb .com
Aug 10 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
24590
by: Hal Vaughan | last post by:
I never noticed this before, but when I run an external program through Runtime, like this: Runtime rt = Runtime.getRuntime(); System.out.println("Running external command: " + sCommand); try {Process p = rt.exec(sCommand);} catch (Exception e) {System.out.println("Cannot Run Command: " + sCommand + ", Error: " + e);} the external command is asynchronous -- completely spun off as a separate thread or process. Is there any way to...
1
5085
by: Hal Vaughan | last post by:
I've been using Runtime.exec() like this: Runtime rt = Runtime.getRuntime(); try {Process p = rt.exec("MyCommand.bat");} catch (Exception e) {do stuff} When I start my Java classes, I start them with a batch file that changes to my apps home directory. I've tried exec() with a full pathname (which seems to have problems on Windows if it has spaces in it, but I'm not sure if that's really the problem), with just the simple short batch...
9
46605
by: Dario | last post by:
This is a technical C++ post regarding the Microsoft runtime error R6025 Pure Virtual Function Call that sometime occurs in programs compiled with Microsoft Visual C++ 6.0. Please consider the following simple illegal C++ program: class Listener { public: virtual void onEvent(int n) = 0;
5
15956
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived from an Abstract class, I do not believe that this class object is causing me my problem. Below is that message I have posted before to other groups. Question:
8
5164
by: swathky | last post by:
I've tried mutiple things but no go -- (sorry this is so long) I'm collecting a 5 digit number in an input box function and all works fine until a number is passed that doesn't exist in the database. I can't figure out where/how to check that the number exists before I get the error code 2105. Here's my function to get the number that I run when a command button is clicked to open the frmEditLoans form: Public Function...
7
2676
by: Kathryn Townsend | last post by:
We have a customer using our Acc97 Runtime application on a Win 98 machine that was recently upgraded to WinXP Home Edition Service Pack 1. Shes states RAM is 228, CPU Pentium II 398 MHz , Hard drive 7.85 GB with 795 MB free space. Retail Access is NOT installed, Word and Excel 9 ARE installed. When first starting our app she got the message "Microsoft Acess can't start because there is no license for it on this machine." She...
1
4229
by: Robert | last post by:
Im using Windows XP Pro, SP2 (error was still with SP1), P4 3.4Ghz, 1Gb Ram, NVidia FX1100 Graphics, Using Programs such as Autodesk Inventor & AutoCAD. I don't have a clue what Microsoft Visual is but when using the Windows Explorer I get a message saying Microsoft Visual C++ Runtime Library....Runtime Error telling me that the application will be terminated. Click the OK button and all windows explorer related programs crash closed. Im...
7
1299
by: Jay Loden | last post by:
Hi all, First, apologies if anyone gets this twice, but it took me quite a while to figure out that Python.org is evidently rejecting all mail from my mail server because I don't have reverse DNS configured. Anyway: I'm not even sure how to phrase this question properly or the right terminology on this so bear with me. What I'm looking to find out is
10
13335
RMWChaos
by: RMWChaos | last post by:
WinVista/IE7 I am getting some weird errors only in IE7, but not in FF2.0.0.8 or NN9. It even happens on this website when I click "Sign In". The error is: "A Runtime Error has occurred." "Line:xxx" "Error: Object expected" and Debug says: "Microsoft JScript runtime error: Object expected."
0
999
by: rhyspatto | last post by:
Hi, I have a problem but cannot figure out a good solution to it. I am trying to create a form that creates a bunch of panels during runtime, and I want to be able to send commands (such as false visibility, etc) to the panels also during runtime. Once I create a bunch of panels (each using the same 'creation' code), how can I call them up again to send commands to them? I figure I can add them to an array and call them using:...
0
9916
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10696
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10782
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9531
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7932
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5761
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4174
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.