Hello @xzrokeman, welcome to the forums
I think the JS part of your HTML code shouldn’t work, because
st.write(string, unsafe_allow_html=True) fallbacks on
st.markdown(string, unsafe_allow_html=True) which removes any JS tag from the app (you can actually write code that breaks in the JS tag to validate this). You can also see the script have disappeared in the page source on the web browser.
Anyway the sticky should work without the JS
Can you reference your issue in Are you using HTML in Markdown? Tell us why! ? That’s a good example on how to use HTML/CSS to sticky a header !