New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link to external resource under the same domain #879
Comments
See this code for anchor click handling: Line 228 in ae6abf8
It is setup during go-app startup: Line 130 in ae6abf8
Without changing go-app code, the onClick events are going to be captured on anchor tags and treated as internal navigation if the host matches. You can get around this by setting window.location.href in an on click event: app.A().Style("cursor", "pointer").OnClick(func(ctx app.Context, e app.Event) {
u, _ := url.Parse(app.Window().URL().String())
u.Path = "/other"
app.Window().Get("location").Set("href", u.String())
}).Text("/other path on same host"), This is exactly what go-app does when navigating to urls that it thinks are external: Line 302 in ae6abf8
|
Thank you! My only problem with this is that the user is no longer able to right click and open the link in a new tab for example or copy the link to e.g. share etc. because of the missing href on the anchor itself. I know that I could tweak the onclick event to open the link in a new tab everytime but for anything else I dont think this is real solution. I saw that the navigate function gets avoided when either two events are set or the download attribute has some content and I build a "External" component to get my desired behaviour:
|
@maxence-charriere I think that there should be a way to do that by adding something to the HTML element, that tells go-app to not handle this A tag. Having to work around this limitation looks odd. |
Just fixed this in https://github.com/maxence-charriere/go-app/releases/tag/v10.0.3 |
Hi there,
I was wondering, is there a way to forcefully redirect to an external resource under the same domain?
I have two apps hosted under the same domain name and whenever I try to link to a different page the client side router tries to take over. Am I missing something or is this supposed to happen?
I don't have a wildcard route or something that matches the URI that I'm calling or is the router trying to match everything?
The text was updated successfully, but these errors were encountered: