user2643864
user2643864

Reputation: 651

How to embed javascript chat client into C#

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);
})();

Upvotes: 1

Views: 610

Answers (1)

Sam Plus Plus
Sam Plus Plus

Reputation: 4601

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.

Upvotes: 3

Related Questions