Hi All,
I have tried all the methods posted here to redirect to an external url. But all of them will open a new tab. Is there any way to redirect to url from the same tab of streamlit? Thank you!
Hi All,
I have tried all the methods posted here to redirect to an external url. But all of them will open a new tab. Is there any way to redirect to url from the same tab of streamlit? Thank you!
import streamlit as st
import streamlit.components.v1 as components
# embed streamlit docs in a streamlit app
components.iframe("https://www.baidu.com")
Thank you for your response! I think iframe will embed the external url in the current streamlit page. But I want to redirect the whole streamlit page to the external page. for example, the current streamlit page has its url like: http://localhost:8501 to https://www.baidu.com on the same tab without opening a new tab. Is there any solution for it? thank you again!
I think you can do this with a HTML link and setting the link target. E.g.:
st.markdown('<a href="..." target="_self">...</a>', unsafe_allow_html=True)
But note that on Streamlit Cloud, this may not work perfectly in some cases. (The app is shown within an iframe on Streamlit Cloud and some websites can’t be opened within an iframe. That’s why we set the default link target to _blank
in the first place so that the link always opens in a new tab.)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.