I am building a website using angularjs. There are some link in the footer that are linked to the views in states like other pages in an angularjs website. The problem I am facing is, when i click the links in footer, view changes/includes perfectly but the scrollbar remains at its position(displays footer). I tried to use target = "_top" attribute in the link tag but its not working.(though i don't need it, target = "_blank" is working perfectly). Please give me a solution for this, i need to to see the header(top of the page) when i click any link on the website. USING ui-sref TO INCLUDE VIEWS AND NOT HREF.
-
1Possible duplicate of [Changing route doesn't scroll to top in the new page](https://stackoverflow.com/questions/21055952/changing-route-doesnt-scroll-to-top-in-the-new-page) – fluoresce Jun 26 '17 at 06:21
3 Answers
<a href="http://foo.com" target="_top">a link</a>
Tells the browser to navigate to "foo.com" not in its own frame, but in the topmost frame. If the current frame is the topmost frame, the URL will open in the same window.

- 373
- 5
- 20
I think you want to make a page with jumps? you can create "jumps" or links to different places on a page. For example, I have created a "Top" and "Bottom" page jump at the top and bottom of this page. They are nothing but links to places on this page. Click on them and they will take you to the top or bottom of this page. Page jumps can be very useful on very long pages of information.
There are two parts to creating page jumps. First, there is the jump or link. It's created much like you would create any link.
<center>
<a href="#Top">Top</a>
| | | |
<a href="#Bot">Bottom</a>
</center>
Ok, that was the first part; the link. Now, we need to mark the spot on the page to jump to. We do that with the tag or statement. These tags will be placed where ever you want the page to jump to. The "Top" and "Bot" tags are shown below. These were placed at the top and bottom of my page.
<a name="Top">
<a name="Bot">
the NAME tags used have to match up with the links shown earlier in this tutorial. Also, notice that in this case no "#" (Pound) symbol was used. Note that the use of "Top" and "Bot" was completely arbitrary. You can use whatever words you would like, just keep in mind that they are case sensitive. "Top" is different than "top". I hope this helps.

- 1,359
- 3
- 18
- 39
-
I am using ui-sref and not href.Trying to create a SPA using angularjs. – Arpit Banati Jun 26 '17 at 13:50
If different states are going to be loaded on each link click, you can use window.scrollTo(0, 0)
in their primary controllers when the state gets loaded.

- 800
- 1
- 8
- 15