Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS/HTML: Disable link "hover" text

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?

like image 368
James T Avatar asked Apr 09 '11 14:04

James T


People also ask

How do I turn off hover in CSS?

To remove the CSS hover effect from a specific element, you can set the pointer-events property of the element (the hover behavior of which you want to disable) to “none”.

How do you disable a link in CSS?

To disable a HTML anchor element with CSS, we can apply the pointer-events: none style. pointer-events: none will disable all click events on the anchor element. This is a great option when you only have access to class or style attributes. It can even be used to disable all the HTML links on a page.

How do you make a link disabled in HTML?

It is still possible to disable a link by following 3 steps: remove the href attribute so that it can no longer receive the focus. add a role="link" so that it is always considered a link by screen readers. add an attribute aria-disabled="true" so that it is indicated as being disabled.


3 Answers

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>
like image 148
NKCSS Avatar answered Nov 13 '22 20:11

NKCSS


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.

like image 21
SmartPC Avatar answered Nov 13 '22 19:11

SmartPC


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;
    });
});
like image 31
d.raev Avatar answered Nov 13 '22 19:11

d.raev