Internal Anchor without creating history

Asked

Viewed 32 times

-1

I am facing a problem related to the internal anchors of html, every time I use one, a history is created for each anchor (see the image below). Is there any way to stop you from creating that history ?

Histórico

1 answer

0


With Javascript, you can create a function to open your links using location.replace().

The replace() method Replaces the Current Document with a new one.

The Difference between this method and assign(), is that replace() removes the URL of the Current Document from the Document history, meaning that it is not possible to use the "back" button to navigate back to the original Document.

Source: Location replace() Method

In free translation:

The method replace() replaces the current document with a new.

The difference between this method and assign() is that replace() removes the current document URL from the document history, which means that it is not possible to use the "back" button to navigate back to the original document.

Take this example:

function abreLink(e, url) {
    e.preventDefault();
    window.location.replace(url);
}
<a href="http://google.com" onclick="abreLink(event, 'http://answall.com');">Abrir link sem deixar histórico</a>

  • that’s exactly what I was looking for. Now taking advantage of this question, is there any way to call this function, using php’s header ? Example: Header("Location: index.php? email=". $email." abreLink");

  • The header('Location: ...'); follows the same principle. It turns out that it is only recorded in the history page that the user drops at the end.

  • 1

    Thank you so much for everything !

Browser other questions tagged

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