Scroll to component's iframe after some event

Hello all

I am using a simple component, inspired by this post by @thiago Code snippet: create Components without any frontend tooling (no React, Babel, Webpack, etc)

I am running some custom JavaScript inside the index.html. But mostly, what I would like to do is upon finishing the window.load event, for the parent window (so the streamlit app/main website) to scroll to the component’s iframe. So in other words, as soon as the component is loaded inside its iframe inside the main web app, I want the window to scroll to the position of that iframe.

I tried to adapt the original code that includes the auto resize feature by adding a scroll trigger, but no success:

    window.addEventListener("load", function() {
        window.setTimeout(function() {
            setFrameHeight(document.documentElement.clientHeight);
            window.parent.document.querySelector("iframe").scrollIntoView();
        }, 0);
    });

Any ideas?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.