Home >Backend Development >PHP Tutorial >javascript - How to bring the content of the iframe back to the top outside the iframe
As shown in the picture, how to click the go top button outside the iframe to make the content in the iframe return to the top.
I tried several times but it doesn’t work. Is there anyone who has done it?
The premise is that the iframe page cannot be modified.
As shown in the picture, how to click the go top button outside the iframe to make the content
in the iframe return to the top. I tried several times but it doesn’t work. Is there anyone who has done it?
The premise is that the iframe page cannot be modified.
<code>var iframeElement; // 自己选择iframe iframeElement.contentWindow.scrollTo(0, 0);</code>
I have no solution for cross-domain issues
DEMO
Register the slide to top method in the document of the iframe. When the external page triggers a click event, it first finds the iframe and then calls this method
Did you do it on the local page? That doesn’t work, try setting up a server