I have a node-webkit app and am wondering if there is a way to target just node-webkit specifically? I need to run some functions only if the client browser is node-webkit.
Thanks
I have a node-webkit app and am wondering if there is a way to target just node-webkit specifically? I need to run some functions only if the client browser is node-webkit.
Thanks
I've just been doing this:
//detect node-webkit
var isNodeWebkit = (typeof process == "object");
if (isNodeWebkit)
{
console.log( 'in node-webkit v' + process.versions['node-webkit']);
//node webkit specific code
}
ie, checking if 'process' is a valid object reference.
Maybe you can tell it by testing process.versions['node-webkit']
.
For 'http://' protocol apps i came with a hack solution: 0===navigator.plugins.length?!0:!1;
following logic is most precise:
var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
var isNodeWebkit = false;
if (isNode) {
try {
isNodeWebkit = (typeof require('nw.gui') !== "undefined");
} catch(e) {
isNodeWebkit = false;
}
}
referred from: https://videlais.com/2014/08/23/lessons-learned-from-detecting-node-webkit/, thanks to the author:)