jQuery scroll to top of iframe parent

前端 未结 5 766
长情又很酷
长情又很酷 2021-02-05 05:48

I have an iFrame with a feedback form in it. After the user clicks submit, I want use parent window to scroll to the top. I know I can scroll to the top of a page with:

<
5条回答
  •  终归单人心
    2021-02-05 06:31

    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');
    };
    

提交回复
热议问题