Ben Scmidth
Ben Scmidth

Reputation: 1335

HTML Link doesn't work properly sometimes

I am using a local server for my applications and sometimes when I created a button or a link to another page in a new tab, it turns out to not working properly. It's not always like this, but sometimes, might sound silly. I give example below.

Let's say my application is **programmingworld** which exists in www folder, then in index.html file, I create a link for a button like this

<a href="www.google.co.uk"  ><div class="button" id="button=popup">Download Codes</div></a>

When I open it in a browser and click the button, sometimes it goes to http://localhost/programmingworld/www.google.co.uk where nothing is displayed on the page. It supposed to be www.google.co.uk in the new tab where I can see the google homepage.

Can you please tell me why?

Upvotes: 2

Views: 11066

Answers (5)

TechnoCF
TechnoCF

Reputation: 178

To make sure that the link goes to where you intend and not where it goes try adding // or http://.

Example: <a href="//www.google.com/">Google</a> or <a href="http://www.google.com/">Google</a>

With // it will try http and https.

Upvotes: 2

vectorbooster
vectorbooster

Reputation: 105

You're missing https:// before www.google.co.uk

So you're markup should look like this:

<a href="https://www.google.co.uk">
  <div class="button" id="button=popup">Download Codes</div>
</a>

you can also do it like this (no https):

<a href="//google.co.uk">
  <div class="button" id="button=popup">Download Codes</div>
</a>

Upvotes: 1

Kendall James
Kendall James

Reputation: 23

I would most definitely suggest using https:// I've had similar problems such as that, and in order to fix them try adding https.

Upvotes: -1

LambethWalk
LambethWalk

Reputation: 96

Because you haven't included the protocol in your URL. it must start with either http:// or https://

Also, remove the div from inside the anchor tag.

Your question suggests that you need to do a little bit more testing on basic html.

Upvotes: 0

Kornelia Kobiela
Kornelia Kobiela

Reputation: 477

You should write:

<a href="http://www.google.co.uk"  ><div class="button" id="button=popup">Download Codes</div></a>

If you didn't write http:// at the the beginning of the hyperlink, it will be search you your local directories or files.

Upvotes: 2

Related Questions