New tab opens locally but not when deployed

Continuing the discussion from A new tab doesn't open up in my web-browser if I run the streamlit-python script:

Hi @thiago Iโ€™m having a similar issue using the webbrowser package. When I test it locally, it works as expected and the new tab opens. However, it does not open in the deployed version.

Any ideas why this might be happening?

if st.button('๐Ÿ’ญ Share Feedback', use_container_width=True):
        url_feedback = ""

webbrowser can open a browser only in the same computer it is running, not in a different computer.

1 Like

Hi @kaankorkmaz

Thereโ€™s a related conversation here and from this conversation I proposed a tweak as follows:


The following code will open a new page upon clicking on the button:

import streamlit as st
from streamlit.components.v1 import html

def open_page(url):
    open_script= """
        <script type="text/javascript">
  '%s', '_blank').focus();
    """ % (url)

st.button('Open link', on_click=open_page, args=('',))

Hope this helps!

Best regards,

1 Like

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