Opening a web page in another tab

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.

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.

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…”.

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.

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.

1 Like

Awesome :slight_smile: 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.

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