Jos_Pols
(Jos Pols)
April 11, 2025, 12:08pm
1
Just started to look at Xojo. Working on the examples and tutorials. Thought I would ask a quick question: I have 2 web pages. On WebPage_1 I have a button. On the button press I would like to open the WebPage_2 in a new browser tab. How is that done?
I have tried searching this forum and the documentation but cant seem to find the obvious or that works for me. I know that I can use WebPage2.Show but that opens in the same tab. I want to know if I can open it in a new tab.
David_Cox
(David Cox)
April 11, 2025, 1:08pm
2
Session.GoToURL("https://www.mywebdomain.com/?page=WebPage_2", True)
Then handle it in the App.HandleURL Event.
Many browsers have this turned off by default.
Jos_Pols
(Jos Pols)
April 11, 2025, 2:03pm
3
Thanks David. Is there a way to test that locally, using localhost 127.0.0.1? I tried but cant get that to work.
You need to have “http://127.0.0.1/ …”, if you have a certificate configured locally you can try “https://127 …”.
Jos_Pols
(Jos Pols)
April 11, 2025, 2:45pm
5
Ian, thanks but I cant get this to work. I tried:
http://127.0.0.1:8080?page=WebPage_2 => That reloads WebPage_1 (not 2)
What would be receiving the “page=” parameter on this URL? Do I need to trap for that somewhere or is Xojo handling that?
Not using the “page=” parameter results in a 404 error.
AlbertoD
(AlbertoD)
April 11, 2025, 2:49pm
6
You need to add code to Handle the URL and show WebPage2 instead of the default WebPage.
Edit: the example (that comes with Xojo) called ‘Providing a WebService’ uses the HandleURL
In Session.Opening.
See this post for implementation, and the next post after that has an example project.
First, don’t use ExecuteJavaScript for this. Use WebSession.GotoURL .
Session.GotoURL( "https://127.0.0.1/?page=somePage", True )
Second, you need some way of determining where to send the user when the request comes in. This is typically done in Session.Opening. You’ll parse the path or querystring and react accordingly by calling whatever target page you want to show the user. So something like:
Sub Opening() Handles Opening
if Session.URLParameterExists( "page" ) then
select case Sess…
1 Like
Jos_Pols
(Jos Pols)
April 11, 2025, 3:32pm
8
Awesome Your example project does the trick. Thanks to all.
1 Like
Glad I could help. Don’t forget to mark a solution that it’s easier for others in a similar situation to quickly find it in the future.
Jos_Pols
(Jos Pols)
April 11, 2025, 3:39pm
10
Done! Thanks again. I think I’m going to enjoy Xojo. Its been a few years since I tried a new development tool but it looks pretty nice so far!
2 Likes