Ad

HTML Link Not Going To External Site

- 1 answer

I have been running a localhost website with react.js while I am building a website and when I am trying to link to an external site (e.g. youtube) it ends up going to a link like this:

http://localhost:3000/www.youtube.com

while I am trying to go to:

https://www.youtube.com

I am using this to get my link:

<a href='youtube.com' target='_blank' rel='noreferrer'>YouTube</a>
Ad

Answer

You need to specify the protocol, or put // at the start of the href attribute. For example: Try using a protocol like http:// or // to external links like this :

 <a href='https://youtube.com' target='_blank' rel='noreferrer'>YouTube</a>

See this good answer on SO : https://stackoverflow.com/a/8951636/6028607

Ad
source: stackoverflow.com
Ad