Solved

"object required" in VBScript

Posted on 2004-04-07
5
2,868 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
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
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 22

Expert Comment

by:Snarf0001
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
That's it!  The document wasn't fully loaded.   Thanks so much.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now