Streamlit-js-eval not executing javascript code

Hi all,

As per Force Reload of Webpage, I’m trying to refresh/reload my page calling the snippet after st.button(): streamlit_js_eval(js_expressions="parent.window.location.reload()"). However, it fails to do so and all of my previous my session_state + widget inputs still remain. I could’ve sworn this worked when I first tried it out, but I’m not sure if its because of the version of streamlit (v1.26.0) and streamlit-js-eval (0.1.5) I’m using in my environment.

Hi @pr00001, st.rerun should do instead, provided your page is in a function.


Hi Shawn,

Oddly enough, the session_state variables don’t clear even after using st.rerun

That is expected. st.rerun does programatically the same than selecting “Rerun” in the hamburger menu, it reruns the script within the same session. Indeed very different from the browser reloading the page, that starts a new session. For that you do need JS.

Unfortunately I don’t know how to fix yous JS issue.

Is there any solution


Can you please create an issue in the GitHub page of SJE so that we can look at it together? I just randomly found this page via Google search.

The following code works, in the latest version of SJE (0.1.7), with streamlit 1.31.0 and Python 3.10:

#!/usr/bin/env python

import streamlit as st
import streamlit_js_eval 

if streamlit_js_eval.bootstrapButton("Check"):