-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Problem
I developed an application that relies on interactive database queries. The idea is to allow for digging deeper into the database by clicking onto interesting keywords in a results table. This has been implemented by HTML markup around keywords to generate hyperlinks with query params that are evaluated in my application using st.experimental_get_query_params
.
The links look like the following
<a href="/?q=keyword target="_top">keyword</a>
The _target
attribute should make sure, that links are opened in the same browser tab as the main streamline application. However, the interactive elements in streamlit are embedded in iframe
s with the sandbox
attribute set in a way that _top
navigation is not allowed.
Thus, depending on the browser links open in a new tab or do not open at all, both of which is undesired.
As I cannot invoke Python code from the hyperlink, I cannot use st.experimental_set_query_params
to circumvent the issue.
Solution
MVP: Add allow-top-navigation
or allow-top-navigation-by-user-activation
to the default sandbox
attribute of iframe
s.
Possible additions: Having this configurable via the .streamlit/config.toml
might be useful to have a compromise between functionality and security, if needed.
Additional context
This request seems to have been asked for by multiple people, e.g. https://discuss.streamlit.io/t/is-there-a-way-to-allow-top-navigation-within-an-iframed-component/40193, https://discuss.streamlit.io/t/navigate-to-new-page-in-multi-page-app-using-link-in-aggrid-cell/26319
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.