GoToURL problem with opening new tab on Safari via button.Pressed

I’d like to use a button to open an external URL (not a page from my web app) in a new tab. I found the GoToURL and to set the second parameter to True, which should work. However, I am finding that this is not working on Safari but did in Chrome. In Safari, I did not see any notification of an attempt to open a new tab (no blocked popup)

me.GoToURL("https://www.google.com/", True)

Using a Link does open a new tab on Safari, but only when I set the URL and Target to NewWindow in Inspector. For the design of my app, I’d like to use a button but will use a Link if that is the way to go. Does anyone know how to get the button.Pressed event with the code above to work on Safari?

What about using a WebLink with the Appearance set to Button?

For security, Safari (and probably others) will block certain APIs when they aren’t called as a direct user action. When you press a button in Xojo, it sends the event to the server, the server executes your code and sends back the outcome to the browser. Safari won’t consider that a “direct user action”.

1 Like

I get “Pop-up Window Blocked” warning with Safari, once I unblock them then Safari opens google without problems (in debug mode on a mac):
image

Maybe one of your settings is to not allow pop-up windows and not show that warning?

Oh my gosh! I didn’t even know that existed! Haha thanks

Possibly. I think I will go with the Appearance style of a button since the link works nicely

Thanks for the replies!

2 Likes