Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

how to keep page scroll position ?



  • when i use ons back button the shown page kept scroll position, but when i use javascript like this code

                document.querySelector('#myNavigator').pushPage('tempRegister', {
                    data: {
                        title: ''
                    }
                });
    

    shown page scroll moved to the first, but i need to have prevoius position. is there any idea ? thank you



  • To get current scroll position:

    var scroll = document.querySelector('#page1 .page__content').scrollTop;
    

    To set it:

    document.querySelector('#page2 .page__content').scrollTop = scroll;
    

    or

    document.querySelector('#myNavigator').pushPage('tempRegister', {data: '...'}).then(function(page) {
      page.querySelector('.page__content').scrollTop = scroll;
    });