Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetElementsByName IE8

Status
Not open for further replies.

jimwal0367

Programmer
Dec 3, 2005
24
GB
Just changed from VB6 to VB2008.

After some investigation, I have found that IE8, has changed regarding GetElementById and GetElementsByName.

My old VB6 code used to bind to certain places on a webpage, using this code

HTMLDOC = objIE.document.getElementById("mainframe")
But IE8 is case sensitive and the actual name of the Frame is not Frame ID but Frame name.

So I changed my code to reflect this to

HTMLDOC = objIE.getElementsByName("mainFrame")

But on running my code HTMLDOC equals nothing.

Declarations as follows:

Dim objie as Object
Dim HTMLDOC As mshtml.HTMLDocument.

Code I am trying to run:

objIE = oWin
HTMLDOC = objIE.getElementsByName("mainFrame")

Any ideas why HTMLDOC is not binding to the frame

 
[0] Name is name and id is id. It is by overly friendly error tolerance that one extrapolates to another. It can be tightened up anytime without prior notice.

[1] Id (theoreically) is unique over the page. Name does not need be. And it is why the methods are called getElementById() and getElement[red]s[/red]ByName().

[2] Hence, I would say, every single line quoted have some sort of problem.
[tt]
[red]set[/red] HTMLDOC = objIE.document.getElementById("mainframe")
[red]set[/red] objIE = oWin
[red]set[/red] HTMLDOC = objIE.getElementsByName("mainFrame")[red](0)[/red] 'if exists, ie, .length>0[/tt]
 
oh, this .net forum. Sorry! thought it were vb6 forum.
 
SET HTMDLDOC = objie.

Only works in VB6 not VB2008
 
Yes, "set" is no longer in vb.net syntax. Sorry again for the confusion on that part. (I actually thought the thread for unknown reason deleted from vb5/6 forum until I navigated to vb.net to re-discover the fact that I posted to a vb.net thread!)
 
Thanks for the reply - does any vb.net expert know the answer to this problem
 
Think I may have cracked it - just seen something in another piece of code that may help, looks like a re-write of code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top