Solved

"object required" in VBScript

Posted on 2004-04-07
5
2,904 Views
Last Modified: 2007-12-19
First off, I'm new to this, so my apologies if the question is stupid.   I'm writing some simple VBScript to reference various attributes of the "document" object for an HTML page.  Sometimes (not always), when I do something like document.getelementbyid("name").whatever, it gives me a Microsoft scripting error telling me that the object is required.   I've tried declaring a variable and pointing it to the document."name" (without the quotes) object and then referencing the properties and/or methods, and same thing.  It's almost as if the DOM is not being recognized.   Is my environment set up wrong?

THANKS!!
0
Comment
Question by:rjdipietro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10779456
you might be interested n these links

DOM 2 Reference
http://zvon.org/xxl/DOM2reference/Output/index.html

VBScrpt Reference
http://www.sloppycode.net/vbscript/search.php


Im just throwing some ideas at you, maybe you might be able these sites useful


0
 
LVL 23

Expert Comment

by:Snarf0001
ID: 10780108
As a first step, check the spelling of the "name", and make sure it is defined as an ID as well, not just Name.  If you get that error message, it's simply telling you that the element you're requesting does not exist.
0
 

Author Comment

by:rjdipietro
ID: 10780160
Thank you for your response.   Yes, I sort of went through the first troubleshooting steps already.   The spellings and syntax are all ok.  Some of the code actually works in other HTML pages.  I know it sounds crazy, but it's true.   This is what happens when I take my car to the mechanic, too.  :)
0
 
LVL 10

Accepted Solution

by:
Kavar earned 125 total points
ID: 10781055
What I have found with working in this area is that you need to make sure the document is FULLY loaded...

i use a
maxTimeout=10
start=timer
do while ie.busy=true and timer-start<maxtimeout
 wscript.sleep 50
loop
if timer-start=>maxtimeout then
  errOut("Failed to load page fully in a timely manner")
end if
0
 

Author Comment

by:rjdipietro
ID: 10783398
That's it!  The document wasn't fully loaded.   Thanks so much.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question