wails icon indicating copy to clipboard operation
wails copied to clipboard

Open URL directly

Open wantg opened this issue 2 years ago • 23 comments

Is your feature request related to a problem? Please describe.

  1. Open the App
  2. Enjoy pronhub

Faster then

  1. Start Chrome
  2. Open a new Tab
  3. Click the location bar
  4. Select pronhub.com in the recently history
  5. Do lovely things

Describe the solution you'd like

func main() {
    err := wails.Run(&options.App{
        //
        URL: "https://pronhub.com",
        //
    })
    if err != nil {
        log.Fatal(err)
    }
}

Describe alternatives you've considered

No response

Additional context

No response

wantg avatar Jul 01 '22 15:07 wantg

Webview is a better project for this use case https://github.com/WebView/webview

leaanthony avatar Jul 01 '22 19:07 leaanthony

I've actually wanted this feature for a while, but for legitimate use cases. Just because wails offers far easier window customisations, so after seeing your feature request and some trial and error I had it working with an external URL I used a custom asset handler, it's not the prettiest solution, but it works for everything I needed it to. Not posting code because I don't know how leaanthony would feel about it, just letting you know it's possible.

brody192 avatar Jul 02 '22 09:07 brody192

Honestly, if you want to wrap external websites there are more appropriate projects. Wails is for desktop apps, not for light wrappers around websites.

leaanthony avatar Jul 02 '22 14:07 leaanthony

I wouldn't be using it for external sites, I would use it for locally hosted web apps that would benefit from having an easy-to-launch wrapper. Sure there are more practical solutions but none of them offer the extensive wails window options that I love so much. I can see that this isn't what you want for the project but there are legitimate use cases, Electron even allows opening a URL in the window, I know it wouldn't be that hard to implement a new struct field so you could use a custom "startURL" with no asset handlers or script injections, maybe just think about it?

brody192 avatar Jul 02 '22 19:07 brody192

I wouldn't be using it for external sites, I would use it for locally hosted web apps that would benefit from having an easy-to-launch wrapper. Sure there are more practical solutions but none of them offer the extensive wails window options that I love so much. I can see that this isn't what you want for the project but there are legitimate use cases, Electron even allows opening a URL in the window, I know it wouldn't be that hard to implement a new struct field so you could use a custom "startURL" with no asset handlers or script injections, maybe just think about it?

forget that frontend just put <meta http-equiv="refresh" content="0;url=https://example.com" /> or <script>window.location='https://example.com'</script> in index.html

wantg avatar Jul 02 '22 19:07 wantg

forget that frontend just put <meta http-equiv="refresh" content="0;url=https://example.com" /> or <script>window.location='https://example.com'</script> in index.html

wow, don't I feel stupid still, what you originally proposed would be a very nice to have

brody192 avatar Jul 02 '22 19:07 brody192

forget that frontend just put <meta http-equiv="refresh" content="0;url=https://example.com" /> or <script>window.location='https://example.com'</script> in index.html

wow, don't I feel stupid still, what you originally proposed would be a very nice to have

I know they wouldn't do it, or I would have made a suggestion last year.

wantg avatar Jul 02 '22 19:07 wantg

I have a desktop app which, in effect, searches a database of links and presents them. I'd like to be able to click a link and have it open in a system browser... is this case possible, and if so how?

For various reasons, Webview is not appropriate for this project.

Thanks!

csterritt avatar Jul 04 '22 20:07 csterritt

I'd like to be able to click a link and have it open in a system browser... is this case possible, and if so how?

Your question should have been in a new discussion but none-the-less, there is an API for this BrowserOpenURL

brody192 avatar Jul 04 '22 22:07 brody192

@overrnet Thanks! That works perfectly, much appreciated.

csterritt avatar Jul 04 '22 23:07 csterritt

I want this feature too, but not only open directly. I want to open an url, and inject a javascript file into it, fetch and send web page data to golang functions to save web contents which load dynamic.

I used electron to implement this feature, inject a js into a webview, and watch DOM events, but this approach does not work in wails.

codepiano avatar Oct 08 '22 17:10 codepiano

@codepiano Not sure I understand -- is this a URL on the web? So you might want to open https://www.yahoo.com and inject JS into that HTML? Or is the HTML you want to modify producing with your go code?

And do you want to display this HTML in the Wails app's window, or in the system browser (e.g., Safari or Edge)?

csterritt avatar Oct 08 '22 17:10 csterritt

@codepiano Leads the user to open a Wails App that contains a modified financial website. that's a good idea.

wantg avatar Oct 08 '22 17:10 wantg

@codepiano Not sure I understand -- is this a URL on the web? So you might want to open https://www.yahoo.com and inject JS into that HTML? Or is the HTML you want to modify producing with your go code?

And do you want to display this HTML in the Wails app's window, or in the system browser (e.g., Safari or Edge)?

actually I want to open an web url like tiktok in wails, then inject a js into it. After user login, the js will fetch information like your favorite videos id... etc, and then send these ids to wails golang backend, download these viedoes and save them to disk.

codepiano avatar Oct 08 '22 18:10 codepiano

@codepiano Leads the user to open a Wails App that contains a modified financial website. that's a good idea.

just want to download some viedoes, 😃

codepiano avatar Oct 08 '22 18:10 codepiano

@codepiano its not a good idea

brody192 avatar Oct 08 '22 22:10 brody192

I have a case to open another page. Users need token to access web site api and the site requires users to login and set token in cookie or storage. If user open app without token, the app will navigate to the website to login and fetch token. then go back to app.

mediawall avatar Oct 21 '22 15:10 mediawall

@mediawall so what is your question? Sounds like you need to implement some sort of OAuth??

brody192 avatar Oct 22 '22 08:10 brody192

This is a very practical function. For example, when doing an unofficial program on a certain website, the verification code problem is unavoidable. We need to be able to display the verification page. For your own website, it is also good to display an extra page, which can be updated on the server without requiring the user to update the program. Jumping is a solution, but it is not easy to use. For example, my program is a local application, but it needs some Participation in web pages... If this is not a technical issue, I hope to listen to the needs of users and not be limited to local.

ZeronoFreya avatar Feb 07 '23 09:02 ZeronoFreya

This will be available in v3 👍

leaanthony avatar Feb 07 '23 09:02 leaanthony

Make Wails great again

wantg avatar Feb 07 '23 09:02 wantg

I also would like to open external URLs. My use case would be to keep multiple websites (external URLs) opened in a split-view window (multiple webview in one window), see also #1997

Zorgatone avatar Jul 26 '23 20:07 Zorgatone

Any updates on this ?

c1ngular avatar Oct 07 '23 11:10 c1ngular