CSS/HTML: Disable link "hover" text
Asked Answered
H

4

7

You know how when you have your mouse over a link, in most browsers, it shows the link in the lower left corner (aka chrome) or in the status bar? How can I disable this?

Hildagarde answered 9/4, 2011 at 14:0 Comment(3)
It seems that you cannot set the statusbar text manually. Read here: developer.mozilla.org/en/DOM/window.statusDreadfully
For the record, I really hate it as a user when pages try to hide information like that. I urge you to reconsider.Carpo
(Just feeling the need to comment on this old question post :) ) Even I, as someone who's often saying "don't ask why but answer the question", am not recommending this, it's only annoying for those who care and those who don't maybe won't even realize it's there, it's not very big after all.Dagmar
M
14

The only way to do this is to remove the data in 'href', and change it to a javascript onclick where you set the window.location to the url you want.

<a href="http://www.stackoverflow.com/">Go To SO</a>

becomes

<a style="cursor: pointer" onclick="javascript: window.location = 'http://www.stackoverflow.com/';">Go To SO</a>
Missing answered 9/4, 2011 at 14:4 Comment(3)
Doing it via JavaScript is probably the only way to disable the URL display, but this raises the question of why? URL display is a valid and important thing, and disabling it is not good for user experience.Lusty
I agree, but it's what Bubby4j wanted. I've seen it done a lot (same as the no right-click javascript alert stuff), it's not a good practice, but you can't stop people from wanting to do it or actually doing it :)Missing
Yes, I know it is useful to give OPs a sense of best-practices, but assuming the querent doesn't know what they are doing is underestimating them. I'm making a web doc in which the link mouseover text is distracting, thus I'm seeking this info.Angulate
U
1

another idea: use a redirector.

Set the link to your own page (aspx) and in that page you do a Response.Transfer. When using aspx, you can use attributes (in the querystring) if you like, to use it for multiple links. This way the user still knows it is a link, but can't see the actual URL when hovering.

Ultimo answered 20/2, 2012 at 11:47 Comment(0)
F
1

I got the same issue today .. and here is a out of the box way to solve it:

Just replace the <a> with a <span> and hide the address in a hidden component,
Then use Jquery to create the page redirect / Ajax.

HTML:

  <span class="fake-link" >
        <span class="url" style="display:none;">www.my-url.com</span>
        Go to My-URL page
    </span>

Jquery:

$(function(){
    $('.fake-link').on('click', function(e){
        var url = $(this).find('.url:first').html(); 
        window.location = url;
    });
});
Fictionist answered 4/9, 2013 at 12:41 Comment(0)
S
-2

Change the onclick event:

<a href="#" id="linkid">Link</a>

<script type="text/javascript">
function changeOnClick()  {
    document.getElementById("linkid").onclick=function(e) {
        location.href="http://www.your-site.com";
        return false;
    }
}
window.onload=changeOnClick;
</script>

You can change the "#" to whatever you want the status bar to show.

Seesaw answered 9/4, 2011 at 14:9 Comment(1)
You should refresh before posting ;)Missing

© 2022 - 2024 — McMap. All rights reserved.