Skip to content

Commit

Permalink
Use JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkolo committed Sep 16, 2024
1 parent 52e9e92 commit 9c2c61b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,25 @@
redirect_url = "https://nutrify-your-life.streamlit.app/" # Replace with the desired URL

# Automatically redirect after 2 seconds
# st.markdown(
# f"""
# <meta http-equiv="refresh" content="2; url={redirect_url}">
# If you are not redirected automatically, click <a href="{redirect_url}">here</a>.
# """,
# unsafe_allow_html=True,
# )


# Use JavaScript with a 2-second delay to automatically redirect
st.markdown(
f"""
<meta http-equiv="refresh" content="2; url={redirect_url}">
If you are not redirected automatically, click <a href="{redirect_url}">here</a>.
<script type="text/javascript">
setTimeout(function() {{
window.location.href = "{redirect_url}";
}}, 2000); // 2000 milliseconds = 2 seconds
</script>
You will be redirected in 2 seconds. If you are not redirected automatically, click <a href="{redirect_url}">here</a>.
""",
unsafe_allow_html=True,
)

0 comments on commit 9c2c61b

Please sign in to comment.