1

I am using .NET 4.0 and C# to develop a standard forms application. I have a help menu that I wanted to provide a "Chat" option. We are currently using LiveChat for our "chat client". They provide similar Javascript that you would use in a web browser to use as your chat client. If I have a user click on the "Chat" Menu Item, how could I launch a browser and use this java script to open up a chat session?

(function() {
    delete(window.LC_API);
    delete(window.LC_Invite);
    delete(window.__lc_iframe_current_skill);
    delete(window.__lc_inited);
    delete(window.__lc_lang);
    var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
    lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);
})();
user2643864
  • 641
  • 3
  • 11
  • 24

1 Answers1

3

You can open a window with the WebBrowser Control

and navigate to the a local html file with the javascript chat code in it. Or you could navigate to a remote url with the code in it.

On windows the web browser control uses IE under the hood. I do not know how this would work on other systems.

If you need other types of browser support there is also Awesomium which is more like Chrome's rendering engine, and GeckoFx which is more Firefox's engine.

Sam Plus Plus
  • 4,381
  • 2
  • 21
  • 43
  • There is a [good example](https://code.msdn.microsoft.com/windowsapps/How-to-inject-javascript-f3970459) from Microsoft of using JavaScript code in WebBrowser in Windows Forms application. Also there is a [question](http://stackoverflow.com/questions/153748/how-to-inject-javascript-in-webbrowser-control) by injecting JavaScript in WebBrowser control on StackOverflow. – Didgeridoo May 29 '15 at 09:57