ScrollIntoView to apply to IFRAME only

I have an element inside the page with scollbars that appears on the download page through a JS call before element.scrollIntoView()- and this works fine, as expected.

Now, if I put this page in an IFRAME, the call element.scrollIntoView()not only adds the element inside the iframe to the top of the iframe - if the parent page has its own scroll bars - it also scrolls the parent page to bring the item in question to the top of the parent page .

I understand that this is probably a design behavior, but is there a way to restrain the behavior of "scrollIntoView" for IFRAME only, or are there any alternatives for this behavior (without affecting the parent page).

+4
source share
1 answer

Came up with . I can set the parent scrollTopfor the own element offsetTop. This will make the parent scroll to the position of the element, and the effect will be local to the IFRAME.

+4
source

All Articles