Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 237
Jatin Avatar asked Sep 03 '13 10:09

Jatin


People also ask

How run JavaScript file in background asynchronously?

In general, if you put await new Promise(r => setTimeout(r, ms)); in an async function, it will run all the code before that line, then wait for ms milliseconds without freezing the UI, then continues running the code after that line. See this answer for more information.

What is background process example?

A background process is a computer process that runs behind the scenes (i.e., in the background) and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification.

How do I run a background task in react native?

Import AppRegistry into your component where you want to run the task. And register your task ex: setIntervalTask. js so that it will start running in background when the service is started. AppRegistry.


2 Answers

The flash player and applets use plugins, which are native applications to the OS, (i.e. (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, i.e.: 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.

like image 133
Umur Kontacı Avatar answered Sep 20 '22 09:09

Umur Kontacı


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.

like image 32
Daniel Earwicker Avatar answered Sep 21 '22 09:09

Daniel Earwicker