Calling JavaScript method via COM interface

I am working on a project for the Matlab interface and the Google Earth plugin.

My idea is to use a COM interface in which MATLAB as a COM client and the Google Earth plug-in in Internet Explorer 9 as a COM-Sever.

But so far I still don't know how I can call the JavaScript method from MATLAB to update the Google Earth view in Internet Explorer.

Is it possible to call a JavaScript method via COM?

My second idea is to create a custom web browser based on InternetExplorer, and then built-in custom methods and COM properties so that it can work with Google Earth regarding calls from an external application.

Any help would be greatly appreciated.

Regards, Wang

+3
source share
1 answer

It seems that the only supported Google Earth API is the JavaScript API. Therefore, your approach to implementing Internet Explorer for this sounds reasonable.

I'm not very good at the end of MATLAB, but assuming you can embed a web browser control, you should be able to run scripts.

At the lowest level, the IE web browser implements the IWebBrowser2 interface. This interface provides a Document property that returns the IHTMLDocument2 interface. Call IHTMLDocument2 :: parentWindow to get the IHTMLWindow2 interface.

IHTMLWindow2, , . script IHTMLWindow2:: execScript. , JavaScript IHTMLWindow2 IDispatch: , .

Delphi, execScript: http://www.delphidabbler.com/articles?article=21

.NET Framework, IDispatch (. ): http://www.west-wind.com/weblog/posts/2008/Sep/27/Calling-JavaScript-functions-in-the-Web-Browser-Control

, :

myWebBrowser.Document.parentWindow.MyJavaScriptFunction()

:

myWebBrowser.Document.parentWindow.execScript( "MyJavaScriptFunction();", "JavaScript" )

+3

All Articles