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

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

programmeradmin4浏览0评论

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

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

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??

Share Improve this question asked Oct 3, 2013 at 11:10 Infant DevInfant Dev 1,7499 gold badges24 silver badges48 bronze badges 3
  • 1 Possible duplicate of How to use nodejs to open default browser and navigate to a specific URL – Tomek Rękawek Commented Oct 3, 2013 at 11:14
  • @Tomek: Certainly looks like it, yeah; this answer seems most relevant. – T.J. Crowder Commented Oct 3, 2013 at 11:17
  • @Tomek, the link posted uses another gem. I would be more interested if I can play with it through any javascript method. Can't find a way to do it yet – Infant Dev Commented Oct 4, 2013 at 9:10
Add a comment  | 

2 Answers 2

Reset to default 20

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.

NWJS Stable v0.68.0
Shell.openExternal(uri)
uri {String} A URL to open in system default manner.
Open the given external URI in the desktop’s default manner. For example, mailto: URLs in the default mail user agent.

window.nw.Shell.openExternal("https:google.com.br")

发布评论

评论列表(0)

  1. 暂无评论