Anchor to another page with scroll to the content

Asked

Viewed 4,723 times

3

I have a link on a page that will send me to another page, but I need that when the requested page is loaded, make a scroll for the content I want to focus on.

If it were on the same page, I would have no problem because I already do it at a certain point, but as they are on separate pages, I have no idea how to do that.

2 answers

6


Scroll on the same page just put the element ID in the href:

<a href="#id-do-elemento">Go</a>

To perform on another page the engine is even, just add the ID at the end of the URL:

<a href="outra-pagina.html#id-do-elemento">Outra Página Go</a>
  • It worked! And how would I animate the scroll in this case? Because in this method, it already falls "dry" in Ction, I would like to do an animation.

  • 2

    This "no" is natively possible @Tamiris, but has some alternative solutions like that one, that one and that one. There are also other solutions using server language...

5

The process is almost the same and very simple, just put the nome_da_pagina#nome_da_ancora:

<a href="contato.html#maps">Nos encontre no mapa</a>

But if you do this redirection by javascript (by the tag of your question, that’s what you mean), use:

location.href = 'contato.html#maps';
  • What is "name_da_ancora"?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.