Anderson Green
Anderson Green

Reputation: 31840

Mimicking the features of node-webkit using a client and a server

I'm trying to find out whether it's possible to invoke node.js functions from a web page. Is there any way to make node.js functions accessible from Google Chrome (so that they are run on the node.js server), as shown here?

(I'm aware that it's possible to do this using node-webkit (a non-standard Chromium implementation) without modifying the code, but I'd prefer to do this using an unmodified browser, which will require the code shown below to be modified in some way.)

<html>
    <body>
        <script type = "text/javascript">
            var exec = require('child_process').exec; //node.js function
        </script>
        <p onclick = "exec('firefox')">
            Click here to launch the Firefox web browser.
        </p>
   </body>
</html>

Upvotes: 1

Views: 827

Answers (2)

oknoorap
oknoorap

Reputation: 1953

NW has own method like node exec :

var gui = require('nw.gui');
gui.Shell.openItem('firefox', ,function(error, stdout, stderr) { });

Upvotes: 2

Brad
Brad

Reputation: 163438

No, this is not possible, for clear security reasons.

You only have available to you what the browser gives you. node-webkit is the closest thing available, and does not meet your requirements.

Upvotes: 2

Related Questions