I tried using both scrollTo (y, x) and scrollTop (x-pos), the values ββin brackets are the offset.top values ββof the individual DOM elements. It seems that they work in all browsers at the initial stage, however, updating Chrome to re-submit the form, the page jumps to where it should be for a split second, and then returns to the top. This happens when I jump back to the top of the page before refreshing the page. Does Chrome save any session variable or track page position when updating, so that when you click on the update, the page focuses on the part of the last screen viewed? And if so, is there a way to prevent such a reaction from Chrome? I tried to add setTimeout in the hope that my scrolltop or scrollto (as I said, I tried both) to wait until Chrome responds to the page loading but changes the result.
if ($('.register_box').length > 0) { if ($('.register_box').find('.error').length > 0) { var regbox = $('.register_box').offset(); $('body').scrollTop(regbox.top); } }
I tried the "body", "html", selector shell, window, screen and their combination - no change. I also warned the value for regbox.top and sequentially got the value 699, so I know that it is passing the correct value. Is it necessary to stop the spread or prevent default, and if so, where? Firefox and IE respond correctly. Chrome, on both Mac and PC, no.
Lazer source share