How do I Scroll parent page to top when child page is click within iframe?

后端 未结 5 1325
野趣味
野趣味 2020-12-08 09:50

When someone clicks on a link within an iframe (child page), how do I get the parent page to scroll to the top? The issue is the child page will remain in the same spot of t

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 10:27

    Within the Iframe page.

    window.parent.ScrollToTop(); // Scroll to top function
    

    On The parrent page:

    window.ScrollToTop = function(){
      $('html,body', window.document).animate({
        scrollTop: '0px'
      }, 'fast');
    };
    

提交回复
热议问题