Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Object Expected Error

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> Articles
View previous topic :: View next topic  
Author Message
phil karras
Senior Member
Senior Member


Joined: 15 Jul 2002
Posts: 1697
Location: MD

PostPosted: Tue Jul 16, 2002 6:48 am    Post subject: Object Expected Error Reply with quote

Someone I was helping had the following error pop up on some browsers:

line ##
char 1
object expected

It turned out to be caused by a line like this:
Code:

<body gcolor="#BA8F3F" onLoad="My_preloadImages('image1.gif','image2.gif')">

This is because the function: My_preloadImages was not defined in this html file and was not loaded by a

<script language="JavaScript" src="MyFunctions.js">

type line either.

Once I made a dummy function of that name and placed it in the header section all was well, except of course that the images wanted were not in fact pre-loaded.

This Error Means:
(1) that for some reason a function expected has not been found. It could be that you mis-typed the name MyFunction is different from the following: myFunction, Myfunction, & myfunction to name but a few.
(2) It could be that the function was loaded but too late. Using something like:
Code:

<script ....>
   var = MyFunction();
</script>
.
.
.
<script ..... src='MyLib.js'>
  // Holds all my functions including MyFunction()
</script>

would cause this problem.
(3) An error occured before the function could be loaded which caused the rest of the script to abort. In some very strange cases this error might not be seen by you if the browser for some reason doesn't choke on it, yet all code following this error will NOT HAVE BEEN LOADED! - This has got to be the most difficult to locate, but I'd suggest that if everything looks OK to you, then simply move this function to the beginning of the <script> section and see what happens. By moving each piece from the bottom to the top (one piece at a time) you will eventually be able to locate the defective section.
_________________
Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://jsworkshop.com/bb/viewtopic.php?t=508
Back to top
View user's profile Send private message Visit poster's website
phil karras
Senior Member
Senior Member


Joined: 15 Jul 2002
Posts: 1697
Location: MD

PostPosted: Mon Apr 07, 2003 11:05 am    Post subject: Reply with quote

Another variation is:

Hints on, Error: Object Does Not Exist
http://jsworkshop.com/bb/viewtopic.php?p=2787
_________________
Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://jsworkshop.com/bb/viewtopic.php?t=508
Back to top
View user's profile Send private message Visit poster's website
redmuff
New member
New member


Joined: 14 Apr 2005
Posts: 1

PostPosted: Thu Apr 14, 2005 8:14 am    Post subject: Reply with quote

dude, I fixed this it was really wierd, never seen it before

the browser wasnt accepting the following function template

function doSomething()
{
//do something here
}


it would only accept

function doSomething(){
//do something here
}


notice the difference? the '{' tag had to be on the same line as the function declaration.

This happened when I was doing it as part of an xsl transformation, but I doubt that had anything to do with it.
Back to top
View user's profile Send private message
phil karras
Senior Member
Senior Member


Joined: 15 Jul 2002
Posts: 1697
Location: MD

PostPosted: Mon May 09, 2005 6:49 pm    Post subject: Reply with quote

Interesting, I would never have tripped over that one since I always
use:

function name () {
}

PK
_________________
Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://jsworkshop.com/bb/viewtopic.php?t=508
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> Articles All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.