function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lis WitalisLis Witalis 

Scrolling inside iframe

I have two pages - first one contains iframe component which I'm using to load my second page. I'm using
$('html, body').animate({scrollTop:0}, 'slow');

on my second page but it doesn't work. It works when I'm going directly to my second page (not loaded as a first page's element). How can I fix this?
NagendraNagendra (Salesforce Developers) 
Hi Lis Witalis,

If the iframe is in the same domain as parent please try the below,either ways it works.

This seems to have done the trick:
window.parent.$("body").animate({scrollTop:0}, 'slow');
$(document).ready(function() {
      $("body,html", window.parent).animate({scrollTop:0}, 'slow');
});
This seems to do the trick as well:
$('html, body', window.parent.document).animate({scrollTop:0}, 'slow');

Please mark this as the solution if it helps.

Best Regards,
Nagendra.P