Book Image

NW.js Essentials

By : Alessandro Benoit, Roger Weng
Book Image

NW.js Essentials

By: Alessandro Benoit, Roger Weng

Overview of this book

Table of Contents (17 chapters)
NW.js Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

The Shell API – platform-dependent desktop functions


The Shell API is made of a set of methods that allow you to leverage platform-related tasks:

  • Shell.openExternal(String URI) : This will open any given URI (http://, mailto:, and so on) with the default system application if one has been associated; otherwise, nothing will happen.

  • Shell.openItem(String file_path): This will open any given file with the default system application if one has been associated; otherwise, the Open with dialog will be shown.

  • Shell.showItemInFolder(String path): This will open the given path inside the system file explorer/finder.

Here's a simple example to open Google.com on your default browser:

var gui = require('nw.gui');
gui.Shell.openExternal('http://www.google.com');