使用jquery目标节点-webkit浏览器

时间:2021-09-08 05:41:07

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.

我有一个node-webkit应用程序,我想知道是否有专门针对node-webkit的方法?只有当客户端浏览器是node-webkit时,我才需要运行一些函数。

Thanks

谢谢

4 个解决方案

#1


6  

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.

检查'process'是否为有效的对象引用。

#2


0  

Maybe you can tell it by testing process.versions['node-webkit'].

也许你可以通过测试过程来判断。version ['node-webkit']。

#3


0  

For 'http://' protocol apps i came with a hack solution: 0===navigator.plugins.length?!0:!1;

对于“http://”协议应用,我提供了一个破解方案:0=== =navigator.plugins.length?

#4


0  

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:)

引用自:https://videlais.com/2014/08/23/lessons-learne -from- detect-node -webkit/,感谢作者:)

#1


6  

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.

检查'process'是否为有效的对象引用。

#2


0  

Maybe you can tell it by testing process.versions['node-webkit'].

也许你可以通过测试过程来判断。version ['node-webkit']。

#3


0  

For 'http://' protocol apps i came with a hack solution: 0===navigator.plugins.length?!0:!1;

对于“http://”协议应用,我提供了一个破解方案:0=== =navigator.plugins.length?

#4


0  

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:)

引用自:https://videlais.com/2014/08/23/lessons-learne -from- detect-node -webkit/,感谢作者:)