最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to open devtools automatically when application is starting? - Stack Overflow

programmeradmin1浏览0评论

How to can I configure Node Webkit for open devtools automatically when my application is started?

Can I do it from package.json configure or javascript?

How to can I configure Node Webkit for open devtools automatically when my application is started?

Can I do it from package.json configure or javascript?

Share Improve this question asked Feb 4, 2016 at 14:08 Lai32290Lai32290 8,57819 gold badges69 silver badges104 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 5

You could run some JavaScript on page load which calls showDevTools on the window.

This works with nw.js v0.11.6.

<head>
  <script>
    function openDevTools()
    {
        require('nw.gui').Window.get().showDevTools();
    }
  </script>
</head>
<body onload="openDevTools()">

Further details in the nw.js documentation here: https://github./nwjs/nw.js/wiki/window#windowshowdevtoolsid--iframe-headless

for nw.js 0.13 and newer you can use:

nw.Window.get().showDevTools();

We can enable the devtools by adding "showDevToolsOnStartup":true under developer section in package.json and can open devtools automatically when application is started.

{
    "main": "index.html",
    "name": "nw-demo",
    "description": "demo app of node-webkit",
    "version": "0.1.0",
    "keywords": [ "demo", "node-webkit" ],
    "window": {
        "title": "node-webkit demo",
        "icon": "link.png",
        "toolbar": true,
        "frame": false,
        "width": 800,
        "height": 500,
        "position": "mouse",
        "min_width": 400,
        "min_height": 200,
        "max_width": 800,
        "max_height": 600
    },
    "developer": {
        "showDevToolsOnStartup": true
    }
}

I have looked around for a solution regarding this myself and couldn't really find a satisfactory answer. You might have to try using f12 in javascript or a keystroke solution.

It's not likely to ever happen or be allowed to happen, quite intentionally, as it's considered a security flaw.

https://code.google./p/chromium/issues/detail?id=112277

发布评论

评论列表(0)

  1. 暂无评论