HTML Link doesn't work properly sometimes - html

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
Download Codes</div>
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?

You should write:
Download Codes</div>
If you didn't write http:// at the the beginning of the hyperlink, it will be search you your local directories or files.

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

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>

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.

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

Related

<a> link puts page name at end of url

Sorry if the title is confusing, I wasn't exactly sure how to word this.
Basically what I want to do is make a link, simple enough. The page is tylerofcinema.github.io and if I make a link to say, google.com the url that I get is tylerofcinema.github.io/google.com.
Code is in a repo here, let me know if there is any clarification needed.
Thanks, Diego
You did not include the protocol of the url, causing the href to think it needs to open a page in the same directory.
Try adding http:// (or https://) to your href and it will open the specified url.
<a target="_blank" href="https://tylerofcinema.github.io/r/twitter"><button class="homesmb">Twitter</button></a>
should be a simple syntax error.
My suggestion would be to change the url to the full address like http://www.google.com so that the browser understands you mean the actual google server and not something else. give it a try
just add // before the start of the link, it should work

HTML link to internet does not work

Trying a very basic link through HTML to internet:
<p>Google</p>
No matter what website I try to link to my browser says ERR_FILE_NOT_FOUND and the detail
No webpage was found for the web address: file:///Users/stevemcc101/Dropbox/html/“https://www.google.comâ€
So my browser is always picking up the path to the dropbox folder (or any other folder I save the document in) and not linking direct to the URL.
Sorry I know a basic query but just starting to learn HTML and can't get around this issue. Please help!
Try without the quotes like so:
<p><a href=http://www.google.com>Google</a></p>
if that works then the issue is with your quotes

Is it possible to link to a div without changing the URL (in HTML)?

So, basically, I want people to be able to navigate my website, through links to Divs, but PREVENT the browser from changing the current URL (it adds #divname at the end of the .html file).
I have something like this:
<div id="modalLogin" class="modalLogin">
<!-- random stuff here -->
</div>
And somewhere else I have a link to that Div:
<a href="#modalLogin">
<img class="btnLogin" src="../images/btnLogin.png" alt="Log in!"/>
</a>
But, as I mentioned before, whenever they click those kind of links, the URL changes. I'd like to be able to navigate the website WITHOUT that happening. If at all possible, using just HTML (no JavaScript, no jQuery, no AJAX).
While we're at it, I've seen entire websites not changing their URL at all (even when I've traced the requests and am clearly navigating through different files), and some don't even show you the 'expected address' (the URL on the bottom left of the browser). How do I do that?
Thanks in advance!
P.S.: I've searched this website, and apparently all 'similar' questions ask just about the opposite: how TO change the URL.
I think You Can Use Javascript for This.
//Grab your current Url
var url = window.location.toString();
//Remove anchor from url using the split
url = url.split("#")[0];
SAMPLE JSFIDDLE

Anchor with hash in href attribute is opening a new page

I have never seen this behavior. I have a simple hash link on a website. The link looks like this:
<a href='#view_123'>Click</a>
On my test server, when I click, it simply changes the url to
http://www.myserver.com/mypage.aspx#view_123
And the page does not redirect anywhere. However, when I push this same link to my live server, it causes the browser to redirect to:
http://www.myserver.com/www.myserver.com#view_123
This makes no sense to me. The only way around this is to put the full url of the page in the href with the hash appended to the end, but this is causing me other problems and is not what I want to do.
The only clue I've come across is the MIME type, but I'm pretty sure mine is correct as "text/html".
There is no javascript causing this. I can hover over the link, and the url hint in Chrome shows the incorrect url.
Have you tried changing the target tag?
<a href='#view_123' target='_self'>Click</a>
or
<a href='#view_123' target='_top'>Click</a>

Weird problem with simple HREF link

I'm putting a simple href link inside my html page:
http://search.mastertour.co.il/?mode=page&page=12077&lang=rus
the link can be found at the bottom of the page near the cleopatra head image.
Now, while the page is in a subdomain, the link referes to a TLD but the page cannot redirect to the link. It shows a "half-baked" page while trying to access the link directly (not through the html link) shows the page fine.
Any idea???
Get rid of the window.open(), this is all you need:
здесь
I'm guessing it has something to do with the onclick attribute you have attached. Do you really need it? Also, i'm guessing you're using it to force that link to open in a new tab/window - you really shouldn't, as the user should have that kind of control.