简体   繁体   中英

Start a background process with javascript

In general I am aware that one cannot call system libraries or dll's from javascript in browser. But in many of the application's I see browser starting other processes. For example:

  1. As soon as I open Google Plus, it starts the googletalkplugin.exe (from folder C:\\Users\\Jatin\\AppData\\Local\\Google\\Google Talk Plugin ) in the background. (Can be viewed in Resource monitor)
  2. The same with facebook video chat. For the first time, it asks me to install a plugin and later when I start a chat, it starts a process.
  3. On torrent sites, they provide magnet links. Clicking on torrent magnet link, it opens my systems default torrent client.

In a way, the same with flash and applet.

How do browsers trigger another process and communicate with it? Is there any open standard I am missing?

Ultimately I wish to do video, audio recording with screencast. For screen-recording, Java applet looks like the only solution but applet has its own Issues.

The flash player and applets use plugins, which are native applications to the OS, (ie (mostly) not JavaScript), they are not extensions but plugins. For Chrome see chrome://plugins/ to see the list of installed plugins.

For writing a browser plugin, refer to How to write a browser plugin?

The torrent link is totally different, they are done by registering an url protocol to handle. In other words, you say to the computer that, from now on, I will run any urls which have protocol of torrent , ie: starts with torrent:// . See: Uri Scheme

When the browser sees the uri, it knows that is not handling torrent protocol itself, so it delegates that to OS, which knows what to do with it.

If the browser did know how to handle that, it probably would not delegated that to OS. For example: Google Chrome can handle mailto: links just well without registering mailto protocol to be handled by OS.

You can do this by writing a plugin. It's possible to write plugins that work on most popular browsers, using the same C++ code, using a library called Firebreath

Naturally there is no pre-existing standard plugin that allows the page to start any external application, because that would be a massive security hole and no (sane) user would agree to install such a plugin.

You have to write a specific plugin with capabilities carefully limited to what you need, so the user can agree to let you use just those capabilities. Again, think about how another page might exploit those capabilities before going down this route.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM