LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Web browser and script activeX controls and HTML data

Hello,
 
I'm trying to use the Microsoft Web Browser (IWebBrowser2) and Script (IScriptControl) activeX controls in Labview to evaluate and execute HTML script.  If I wire the web browser control's document object to the object input of the Script control's AddObject method, I can then evaluate/execute script such as "document.f.btnI.focus();" and such (in this case corresponding to Google's home page).  However, there are other expressions that include the "window" object that are proving much more difficult to work with.  Although I can browse the document object's parentWindow object via the property browser, if I try to access that object programatically, I get the error "Error -2147467262 occurred at No such interface supported".  I'm wondering how to include the window object for scripting.
 
I'm writing a content-oriented web crawler.  I've been writing it with pretty low level TCP functions, handling 301/302 "object moved" and "<META HTTP-EQUIV="refresh" CONTENT="0; url=http://millercountyliberal.com/">" redirections manually.  But there are other automatic script-based redirections like:
 
<script language="JavaScript" type="text/javascript">
<!-- window.location="http://www.jrnl.com" -->
</script>
that I'm still trying to figure out how to work with.  As you can see, to work with that one manually involves the window object.  The reason that I don't just let the Web Browser object handle the redirections is because that object often throws script errors, downloads embedded graphics and other unnecessary components, can't handle some non-standard redirections, and sometimes annoyingly crashes.  Any help would be appreciated.  A code sample is attached.  The Web Browser control should already exist on your machine if you have Internet Explorer installed.  The script control may need to be registered before it can be used as follows:
 
regsvr32 "c:\MyDir\XHTTP.dll"
 
Thanks.
0 Kudos
Message 1 of 2
(3,549 Views)
Hi Ted,

This seems to be a problem with the way you are referencing the ActiveX properties.  I would research a little more on the API for these objects.  See http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/iwebbrowser2/document.asp for an explanation of the IWebBrowser2 Document property.  I am suspicious of where you are typecasting the Document variant into the IHTMLDocument2 object and this is where the error is being thrown.

A search of this error code on Google shows that this is a generic error from the ActiveX object, and not a LabVIEW error, although it is confusing since LabVIEW uses error codes in this same range.

Hope this helps!
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 2 of 2
(3,522 Views)