Angular 1.26 version window.history.back () Auto go to top

Source: Internet
Author: User

In version 1.26, the URL ("Www.example.com#xx"), followed by the back, is automatically tuned to the top because the default settings for angular

As long as the config is injected into the $anchorscrollprovider, then run this on the line $anchorscrollprovider.disableautoscrolling ();

Oddly enough, the Chrome browser would have been no problem, and this time it would not have been necessary to change the default settings, but it would have been seen in the chrome viewer.

Misunderstanding:

When Chrome is Window.history.back, it will immediately get the current pageyoffeset and then go back to the location

The FF Viewer will not be able to get the current pageyoffset, but can still go back to the position before the hash.

The above process can go back to the original position, but in taking pageyoffset is not the same.

In the original code will find that angular is going to scroll to the top, but when the default is not set to disable, chrome should be to scroll to the top, but no (this is a bug)

* This test is only done in Chrome and Firefox

Browser logic

var scrolltop = window.pageyoffset| | Document.documentElement.scrollTop | | Document.body.scrolltop;when History Back:chrome First run Eventfirefox first run scroll

Angular 1.26 version window.history.back () Auto go to top

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.