-3

Clicking on a link. The #div is a link that takes the person to a certain part of the page . My url is something like this:

http://link.com.br/#div

and I would like the url was just:

http://link.com.br

I would like to take this #div the end of the url. I think javascript would solve my problem, but I'm a * shit * about it

Please, help :( Thanks!

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103

1 Answers1

0

First approch

... would be to just write the hyperlink as:

<a href="http://link.com.br">http://link.com.br</a>

Second thing,

... using JS!

history.pushState('', 'Current Page Name', window.location.replace('/#div', ''))

This second method would replace the URL with the new one! You can just use the desired URL in the last parameter!

It can be as:

history.pushState('', 'Current Page Name', 'http://link.com.br');

Now, this will update the current URL to the one that is provided in the last paramter (third parameter).

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103