Redirect to a new tab

I want to be able to create a button that when clicked, redirects the user to an external website on a different tab. Currently, the code that I have here:

st.write(f'''<a target="_self" href="{activity["productUrl"]}">
                                    Book this event!

does not redirect to a new tab. Instead, it redirects on the same tab, interrupting the user session. Is there any code I can use to fix this?

The target attribute you are setting is specifically telling it to use the same tab.

You can use target="_blank" so it opens up in a new tab.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.