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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WebBrowser problem

Status
Not open for further replies.

dwhitlow

MIS
Mar 1, 2000
40
US
I am trying to check for a string in the HTML of a web page, so I can pop up a message box if the page points to an Access snap file. I am using 'WebBrowser1.Document.body.InnerHTML' to pull in the page and then using the InStr function. If the PC has IE 5.0 or greater, it works fine. If the user has IE 4, and they navigate to a page with frames, then the 'InnerHTML' statement generates a "Method '~' of object '~' failed." run-time error, and then crashes.
 
Hi

When you say "points to" are you looking for links?
If so then you can directly query the links collection of a document and you can also first check if the document has frames embedded before calling any non-frame functions

document.links

document.frames.length

If it's > 0 then the document contains frames.
You can even query those frames for the links as well.

If you're looking for sample code, reply & I'll see what I can do

Have fun
caf


 
This is an example of the page I am looking for:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
<title>Untitled</title>
</head>

<body>

<object CLASSID=&quot;CLSID:F0E42D60-368C-11D0-AD81-00A0C90DC8D9&quot;
width=&quot;100%&quot; height=&quot;100%&quot;
CODEBASE=&quot;../../../../snapview.ocx&quot;>
<param name=&quot;_ExtentX&quot; value=&quot;16722&quot;>
<param name=&quot;_ExtentY&quot; value=&quot;11774&quot;>
<param name=&quot;_Version&quot; value=&quot;65536&quot;>
<param name=&quot;SnapshotPath&quot;
value=&quot; <param name=&quot;Zoom&quot; value=&quot;0&quot;>
<param name=&quot;AllowContextMenu&quot; value=&quot;-1&quot;>
<param name=&quot;ShowNavigationButtons&quot; value=&quot;-1&quot;>
</object>

</body>
</html>

When I find &quot;snapview.ocx&quot; I want to pop up a text box that tells the user the print button doesn't work when viewing this page, because SnapViewer is actually what they are viewing, not my browser, and to right click in order to print. Yes, some of our users are that dense. Like I said, it works fine in IE5, but not 4.
 
I've been working with the WebBrowser control for a while, but could you try using the debugger and set a watch on the &quot;Webbrowser1.document&quot;.

I guess your error arises because this object is not defined, at the state that you use it.

You should ONLY be accessing the inner html, after one of the following events have occurred:

WebBrowser1_DocumentComplete()
WebBrowser1_DownloadComplete()

This is most likely your problem.
Let me know for further help.
 
I've been working with the WebBrowser control for a while, but could you try using the debugger and set a watch on the &quot;Webbrowser1.document&quot;.

I guess your error arises because this object is not defined, at the stage that you use it.

You should ONLY be accessing the inner html, after one of the following events have occurred:

WebBrowser1_DocumentComplete()
WebBrowser1_DownloadComplete()

This is most likely your problem.
Let me know for further help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top