Anchor with hash in href attribute is opening a new page - html

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>

Related

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
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.

Tag appears to be interpreted as part of a link and thus breaking the link

We have a link on our home page going to a subdomain like so:
dogs.example.com?_ga=1.231775647.1813887044.1412445362
But this produces a 404 error "Cannot find page "_ga=1.231775647.1813887044.1412445362".
If I remove the tag and just navigate to dogs.example.com the page does load. So for some reason the browser is interpreting the tag as part of the link.
Is there a way to prevent that from happening?
You are producing a relative link, not an full http link which you need to change domains try the following:
href="//dogs.example.com?_ga=1.231775647.1813887044.1412445362"

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

target="_blank" behavior in https

I'm still really new to this web server thing.. But, I'm deploying a web site using tomcat. And, I've got a jsp page that has a link in it:
The html for the link is pretty simple:
. When I deploy the website locally, this works fine (it opens a new window with page == href). But, when I run the website using https, instead of creating a new window with the url, it creates a new window and adds "www.website.com" on to the url for the page that contained the link.
I'm wondering:
Is this a behavior of tomcat's SSL encryption, or is it something else?
How would I get the desired behavior (the link opens up a new window with
url == "www.website.com"?
You need to add http:// to the front of the href attribute in your link to the external website.
So, instead of Link text, you need Link text.
The reason for this is that links without the protocol in front of them are treated as relative links, meaning the href property in your <a> tag will just be appended to the base URL of your site. See http://www.w3schools.com/tags/att_link_href.asp.

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.