Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a browser window from a node-webkit app?

I have a desktop application, packaged using node-webkit. I need to open the default browser of the user on click of a link. I am using

window.open("www.google.com")

but this opens a new node-webkit window rather than opening a browser window. How do I open a browser window instead??

like image 826
Infant Dev Avatar asked Oct 03 '13 11:10

Infant Dev


People also ask

How do I open a browser with node?

To use Node. js to open default browser and navigate to a specific URL, we can use the open package. const open = require("open"); open("http://example.com"); open("http://example.com", { app: "firefox" }); to call open to open the URL we pass into it.

Can you use node in browser?

Thanks to some creative engineers, it is now feasible to use Node. js modules in browsers, but not directly. Being able to call Node. js modules from JavaScript running in the browser has many advantages because it allows you to use Node.

How do I open node js in Chrome?

This can be done using open npm package. app. listen(PORT, (err) => { if (err) console. log(err); else open(`http://localhost:${PORT}`, { app: "google chrome" }); });

What is NWJS app?

NW.js (previously known as node-webkit) lets you call all Node.js modules directly from DOM and enables a new way of writing applications with all Web technologies. New way of writing native applications using web technologies: HTML5, CSS3, and WebGL. Full support for the features in browser.


1 Answers

To open a link in the user's default browser, you could use gui.Shell.openExternal("http://website.com"). Checkout the documentation for gui.Shell.

like image 64
theabraham Avatar answered Oct 11 '22 14:10

theabraham