Home » vue » How to redirect to the page on another domain with 'a' tag in Vue js project?

How to redirect to the page on another domain with 'a' tag in Vue js project?

Posted by: admin November 26, 2021 Leave a comment

Questions:

I have an ordinary link to another page in my HTML:

<a href='facebook.com'>

or

<a href='www.facebook.com'>

When I click on it, its redirects me to:

my-domen.dev/facebook.com

How to redirect correctly to page on another domain?

Answers:

You need to specify the protocol if you are attempting to trying to load an external URL.

<p>Right click and open links in a new tab.</p>
<a href="facebook.com">Internal - Will throw 404 - facebook.com</a><br>
<a href="www.facebook.com">Internal - Will throw 404 - www.facebook.com</a><br>
<a href="https://facebook.com">External - https://facebook.com</a><br>

You can read more about it here: Why does an anchor tag's href values need http:// preprended to the URL?