views:

26

answers:

2

Hi all

Here's the thing.

A two-way communication (RPC-style) is needed between Javascript on HTML pages provided by a web server online (with session-management and whatnot) and a windows EXE application running on the PC of the website visitor.

Both are parts of the same 'package' and should be able to communicate.

There is the use of a custom protocol for sure, but some browsers like Chrome & Safari sometimes have issues with custom protocol handling, so it is not reliable enough ...

Another possibility is to build a minimal webserver inside the EXE, so the communication would work with all browsers.

It is possible to develop an extension / plugin for each browsers separately, but it's a daunting task..

The usage of flash / java seems not possible for this task because of sandboxing, but I'm not sure about this ??

Do you have any other ideas ?

Thanks !

A: 

You would need to write a browser plugin to do that.

What are you trying to accomplish?

Byron Whitlock
I think I described what I need to do, two way communication between a process on the web page and another on the local machine of the visitor. regular RPC, send commands from one to another and so on. it is working right now with a custom protocol but some browsers do not perform perfectly with it
Alexander
A: 

You can use an embedded ActiveX (COM) object and communicate between both platforms. I've done it (and would not have believed it possible had I not). It's nasty but it works. In the project I used it on I had no choice (which is about the only reason to ever do this). I built the COM object in C#.net and exposed an interface to COM for use on the page. It goes something like this:

    function doSomethingInteresting() {
        // in your js:
           var obj = document.getElementById('yourObjectId');
           obj.MethodNameDefinedOnYourCOMObject("someParameterValue");
    }

        // and your HTML looks like this; note that you can even catch events thrown from the COM object in Js...
    <body>
    <form>
      <object id="yourObjectId" height="0" width="0" classid="clsid:99999999-9999-9999-9999-999999999999" onerror="oError()" VIEWASTEXT></object>
    <script for="yourObjectId" event="ThisIsTheJavaScriptEventHandlerMethod(parameterName)" language="javascript">
    // event handling here for the COM object
            function yourObjectId::ThisIsTheJavaScriptEventHandlerMethod(parameterName) {
          // you can process the parameterName passed from the object here
            }
    </script>
    </form>
    </body>

Happy coding!

Tahbaza
Tahbaza, the communication is supposed to work on the 4 major browsers, so ActiveX is out of question. Right now IE is not 95% of browser market any more for a long time already ;)
Alexander
The object tag is supported in non-IE browsers, Alexander. Are you saying you must support Linux/Mac?
Tahbaza
Check it: http://www.w3schools.com/tags/tag_object.asp
Tahbaza
yes the object tag is, but the activex technology is not supported by anything else than IE. I maybe missed something, but Firefox / Safari / Chrome do not load activex plugins AFAIK
Alexander