开发者

how to start up a desktop application in client side

开发者 https://www.devze.com 2023-03-11 19:26 出处:网络
In my web page, I have to start a desktop application on the client\'s computer if it\'s installed. Any idea how I can do this?

In my web page, I have to start a desktop application on the client's computer if it's installed. Any idea how I can do this?

If the application is MS Office or Adobe Reader, I know how to start them, but the application I want to start is a custom application. You can not find it on the internet.

How can I open the application?开发者_如何学C


Basically it's not possible to achieve unless an application registers a protocol that will trigger it. If it does that all you need to do is to provide a link using this protocol

yourcustomapp://some.parameters

Another way the 3rd party app can integrate with the browser is if it hooks to it as a plugin. This is how flash apps work etc.

If the app you are trying to launch does not support something like that it's going to be close to impossible to achieve what you want.


The browser sandbox prohibits you from executing local resources, for good reason - to thwart a website destroying your box with malicious code. I've been researching the same functionality.

The only solution I've found is to build an extension in Mozilla Firefox which can launch your app. Extensions live outside the sandbox so they can execute local resources. See this page for how to do that. You may be able to do it cross-browser using crossrider, though I haven't had success with that yet.

You could alternatively build a thick client populated from a web service, and launched from the browser through an extension as mentioned above. This is what I'm doing to get around the sandbox. I'm using local XUL for this.

See my question for additional discussion.


First off - you can't do it using javascript in any sort of a portable mechanism.

If the application is ms office or adobe reader,I know how to startup them

No you don't - you know how to send a document, which the browser associates with these applications and invokes them supplying the name of the local copy of the response. You can't just start the programs.

You just need to do the same for your app - invent a new mime type (the major type would be 'application' and by convention, non-standard minor types are prefixed with 'x-', so you might use application/x-hguser) then associate that mimetype with the relevant program browser side.

i.e: You need to explicitly configure each browser


I already encouter that problem in some complex production environnements.

I do the trick using the following code :

function launch(p_app_path)
{
   var oShell = new ActiveXObject("WScript.Shell");
   oShell.Run('"' + p_app_path + '"', 1);
}

In IE options > Security > Customize the level > ActiveX controls and plugins > Initialization and script ActiveX controls not marked as safe for scripting, set the value to Ask or Active.

It isn't a security problem when your website is enclosed into a specific security context. And as they say, it's not worth it to build a gas plant.


JavaScript alone can't do this. (No, not even with MS Office or Adobe Reader.) Thankfully.

There are a number of old ways, including using ActiveX, which may work for your needs. As others have pointed out while typing this, you can customize responses based on the mime type or the protocol, etc.

Any way you look at it, you're going to need control over the end users' browser. If you're in a close environment where you can dictate policy (users must use a specific browser, with a specific configuration), then you're going to need to do that. For an open environment with no control over the end users, you're out of luck.


I'm actually having a lot of success right now with SiteFusion. It's a PHP client/server application framework that serves out XUL/JavaScript applications from a server deamon running in Apache. You access applications from a very thin client in XULRunner, or potentially off a web page using extensions. Clients can execute on any platform, and they're outside of the browser sandbox so you can access local resources such as executables. It'a a fairly elegant solution, their website provides great examples and documentation, and their forum is very responsive. I actually found a minor bug in passing arguments to local executables, posted a question about the forum, and it was fixed by the chief developer in under 15 minutes. Very impressive, overall!

0

精彩评论

暂无评论...
验证码 换一张
取 消