Can an alert button open up a URL?

What I’m trying to do:
I have an alert, within which I would like to add a button that opens a new tab in the browser based on a URL that is set at runtime.

What I’ve tried and what’s not working:
I know that Alerts have button options, but as far as I can see they are very simple and don’t allow for complex actions such as navigating to a new webpage.

Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

Clone link:
share a copy of your app

You can achieve this uisng two ways

  1. Add a form containing your own buttons to the alert.
  2. Open the link using window.open
if alert('Something',buttons=['Open Link'])=='Open Link':
    from anvil.js import window
    window.open("my_url",'_blank')
3 Likes