Book Image

NW.js Essentials

By : Benoit
Book Image

NW.js Essentials

By: Benoit

Overview of this book

If you are an experienced Node.js developer who wants to create amazing desktop applications using NW.js, this is the book for you. Prior knowledge of HTML5, jQuery, and CSS is assumed.
Table of Contents (11 chapters)
10
Index

The DevTools API


The DevTools API is a part of the Window APIs seen in Chapter 2, NW.js Native UI APIS, and it provides three methods:

  • Window.isDevToolsOpen()

  • Window.closeDevTools()

  • Window.showDevTools([id | iframe, headless])

The first two methods are pretty much self-explanatory, while the third one deserves to be dived deep into.

The most common use of Window.showDevTools is without parameters. This way, you can open DevTools at runtime without having to enable the window toolbar:

require('nw.gui').Window.get().showDevTools();

The first parameter [id|iframe] allows us to set the target frame for which debugging is to be enabled. Let's see an example:

<iframe src= "test.html" id="toDebug" ></iframe>
<script type="text/javascript">
var win = require('nw.gui').Window.get();
win.showDevTools('toDebug');
</script>

This way, DevTools will be enabled only on the #toDebug iframe. Its value can be set to the ID or the object of the iframe element.

The second parameter, headless,...