Onion
Onion

Reputation: 1832

Is it possible to control programs with Javascript?

I am making an html/javascript browser homepage, that could be downloaded to any computer - you simply run the *.html file from your computer and it opens in your default browser; in it you have a compact homepage, with several options - you can make a bookmark list, write notes etc. You can leave it opened as it is just a separate tab.

I'm wondering whether it's possible to use javascript in order to open, for example, windows media player or make it possible for the user to set a default music player. Or even close the previously opened program? Could this be done?

I think it would be best if the user could just set the default programs. Getting the file location is not the problem, is anything else needed?

Upvotes: 2

Views: 240

Answers (4)

Radiotrib
Radiotrib

Reputation: 639

You can do something similar to this using a wrapper like Fluid ( http://fluidapp.com/ ) which encapsulats your page and turns it into a native app (with its own sandbox) There are equivalent programs for other platforms as well as Mac.

Upvotes: 0

Bojangles
Bojangles

Reputation: 101483

You can't do this unless you write a browser extension (plugin), for example.

Most web browsers put a lot of work into sandboxing JavaScript so any malicious users can't compromise the system the client's browser is running on, although older browsers are as watertight as sieves. Modern browsers are a lot better, but there are/may be some holes somewhere. All this security means that JavaScript can't (isn't supposed to be able to) access any part of the client's machine.

Upvotes: 4

krtek
krtek

Reputation: 26597

Any respectable browser will block javascript from accessing anything on the user computer. It is a huge security risk to let a script in a HTML page do something like you want.

Depending on the browser and the configuration, it may be possible, but you absolutely shouldn't try to do it.

You can maybe achieve what you want through a browser extension, but you will have to write it for each different browser your customer are using.

Maybe the best thing to do is write a rich client instead of using HTML/Javascript.

Upvotes: 1

fge
fge

Reputation: 121730

It would be doable if the HTML page were not opened in the browser! The browser makes its best not to allow such things for security purposes.

Not that JavaScript in itself is not able to do this -- the language is used in plenty of other places, see here.

Upvotes: 0

Related Questions