How to scroll to top of iframe from inside iframe?

Member

by dedrick , in category: HTML & CSS , 3 months ago

How to scroll to top of iframe from inside iframe?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by aubrey , 3 months ago

@dedrick 

To scroll to the top of an iframe from inside the iframe, you can use the following JavaScript code:

1
window.scrollTo(0, 0);


This code will scroll the window of the iframe to the top left corner, effectively scrolling to the top of the iframe content. You can add this code to a function and call it when needed, such as when a button is clicked or a certain event occurs.