LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error when trying to call Javascript function in ActiveX Web Browser

Solved!
Go to solution

I have a requirement to call a Javascript function on a web page that is being displayed inside the ActiveX Web Browser control.  I have the control on the front panel, and I use the Navigate method to call up the proper page.  Based on an example I found, I am trying to obtain a reference to the HTML Document so that I can then obtain a reference to the parentWindow.  There is a method of the HTML Window object called execScript that I am trying to call.  See attached image of the code (Close reference calls are not shown, but when I run it they are there).

 

I cannot get past the Property Node that returns the parentWindow reference.  The error I get is as follows.

 

Error -2147467262 LabVIEW:  (Hex 0x80004002) No such interface supported.

 

Any ideas on where to go from here?

 

TP9 Call Javascript.png

0 Kudos
Message 1 of 7
(5,954 Views)
Solution
Accepted by topic author Photon_Dan

Hello,

I have replicated the issue and error you are having and have been trying to figure out what the solution is.

It seems that the problem is only with getting the pointer to the parentWindow.  From what I was reading on MSDN, this may be a limitation in using an ActiveX control in LabVIEW. It looks like Internet Explorer creates the window object, and so by opening it in an ActiveX control you loose access to this higher-level object.

Here might be workaround to executing javascript in your program:

run javascript.png

Let me know if that works for you and if that will work in your program.

 

Jacob R. | Applications Engineer | National Instruments

Message 2 of 7
(5,934 Views)

The workaround is the way to go.  I was given direction from the web developers on our project to go the parentWindow route.  I wonder why they didn't know about the ability for the Navigate method to invoke the Javascript.  Those silly non-LabVIEW folks!

 

Thank you very much for digging on this one!

0 Kudos
Message 3 of 7
(5,924 Views)

Haha, no problem!

Good to hear the workaround works and glad I could help.

Jacob R. | Applications Engineer | National Instruments

0 Kudos
Message 4 of 7
(5,922 Views)

Hi.

 

Im trying to get work this code with an Hta application.

 

One question,

¿Is it needed to close the browser reference at the end?

0 Kudos
Message 5 of 7
(5,265 Views)

Closing references at the end of a program is definitely best programming practice. 

Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(5,170 Views)

You are amazing dude! u solved all my problems. Thanks a lot.

0 Kudos
Message 7 of 7
(3,040 Views)