asticode / go-astilectron

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)
MIT License
4.9k stars 344 forks source link

How to open external url in default browser? #276

Closed lijinsummer closed 3 years ago

lijinsummer commented 4 years ago

I want to open a URL in my default browser. Electron's shell module provide function to support it(shell.openExternal('https://github.com')), but I cannot find similar function in astilectron. Please help me solve it. Thanks.

And I have another question. Can I change the windowOptions after new window? For example when I new window with option frame = false, then resize the window and set the option frame = true.

asticode commented 4 years ago

I want to open a URL in my default browser. Electron's shell module provide function to support it(shell.openExternal('https://github.com')), but I cannot find similar function in astilectron. Please help me solve it. Thanks.

A quick Google search gave me this. However I don't know what's your exact use case.

And I have another question. Can I change the windowOptions after new window? For example when I new window with option frame = false, then resize the window and set the option frame = true.

You can resize the window but won't be able to change options manually.

lijinsummer commented 4 years ago

Thanks for your prompt reply :) My use case is : there are some links in my app, when click these links I hope the url will be accessed through browser, instead of another new window in app.

asticode commented 4 years ago

NodeJS is enabled in your JS code. Therefore you can do require("shell").openExternal("http://www.google.com") in your JS.