A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nwjs/nw.js/wiki/node-main below:

Node main · nwjs/nw.js Wiki · GitHub

NOTE: some content in this wiki applies only to 0.12 and earlier versions. For official documentation on 0.13 and later, see http://docs.nwjs.io

node-main is a field in the manifest format, with which you can specify the path to a Javascript file to run on startup. It is treated in the same way as the 'main module' you would run in Node.js.

The script will be running in Node's context which won't be destroyed across page navigation in Webkit, so it can be used to write some 'background' or 'daemon' like code.

Besides Node's symbols, the following symbols are available in Node's context:

Since the node-main script is the main module of Node.js, it can be referred from DOM context with process.mainModule.

the following code works with node-webkit >=0.3.3

After refreshing the page you can see that the number is increased.

index.html

<html>
<head>
<title>Hello World!</title>
</head>
<body onload="process.mainModule.exports.callback0()">
<h1>Hello World!</h1>
We are using node.js <script>document.write(process.version); </script>
</body>
</html>

index.js

(function(){
  var i = 0;
  exports.callback0 = function () {
    console.log(i + ": " + window.location);
    window.alert ("i = " + i);
    i = i + 1;
  }
})();

package.json

{
  "name": "nw-demo",
  "node-main": "index.js",
  "main": "index.html"
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4