Solved

"object required" in VBScript

Posted on 2004-04-07
5
2,895 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
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 22

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 115
numbers ascending pyramid 101 214
Support for Notepad++ (including downloading & installing a plugin) 5 162
Cygwin - GNU GPL License 1 37
This is about my first experience with programming Arduino.
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.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

828 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