Tuesday, 20 August 2013

Calling javascript within Chrome from C#

Calling javascript within Chrome from C#

We have a .net (C#) application that launches an accompanying web page in
an external browser window, and then needs to communicate with that page
via javascript.
We have successfully done this with Internet Explorer, using
mshtml.HTMLDocument. We iterate over the ShellWindows to find the open
Internet Explorer window, and then can do something like the following:
mshtml.HTMLDocument doc = iExplorer.Document;
mshtml.IHTMLWindow2 win = doc.parentWindow as mshtml.IHTMLWindow2;
win.execScript("myJavaScriptFunction('arg1','arg2')", "javascript");
Is there an equivalent way to do this with Chrome? We can find the Chrome
window, but is there an equivalent API we can call into to execute
javascript on the desired page?

No comments:

Post a Comment