fawave_desktop
fawave_desktop copied to clipboard
node-webkit how to
How to
- How to open a url in my current browser?
- How to let node-webkit comunicate with browser? example get the infomation about the current browser visit page url and title.
- How to let node-webkit application window come to the front when it start?
- How can I package the app and distribute it?
node-webkit google group about how to
Answer
- How to open a url in my current browser?
You can use node's child_process module to open the
open
command, and here is an example: https://github.com/zcbenz/nw-file-explorer/blob/master/node_modules/shell.js
var child_process = require('child_process');
var cmd;
if (process.platform === 'win32') {
cmd = 'start';
} else if (process.platform === 'linux') {
cmd = 'xdg-open';
} else if (process.platform === 'darwin') {
cmd = 'open';
}
exports.open = function (uri) {
child_process.exec(cmd + ' "' + uri + '"');
};
- How to let node-webkit comunicate with browser? example get the infomation about the current browser visit page url and title.
It's different on different browsers, but the general way is:
- make node-webkit listen at a port and receive commands
- write a small program that take browser's url and title and send them into the port that node-webkit is listening
- on safari add that small program to the share button (I'm not sure how to); on opera write a custom button. You have to find out how on different browsers.
- How to let node-webkit application window come to the front when it start?
Use window.focus();
- How can I package the app and distribute it?
Read https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps
window.focus();
not work on my mbp.
windows open: http://stackoverflow.com/questions/118748/windows-console-command-to-open-multiple-pages-in-internet-explorer-7