在链接和< abbr>上禁用浏览器工具提示 [英] Disabling browser tooltips on links and <abbr>s

查看:176
本文介绍了在链接和< abbr>上禁用浏览器工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户将鼠标悬停在某些链接和元素上时,我想要禁止Web浏览器的默认工具提示显示。我知道这是可能的,但我不知道如何。任何人都可以帮忙吗?

I want to suppress the web browser's default tooltip display when a user hovers over certain links and elements. I know it's possible but I don't know how. Can anyone help?

这样做的原因是抑制微格式日期时间的工具提示。 BBC放弃了对hCalendar的支持,因为机器可读日期的外观对于有认知障碍的人以及一些屏幕阅读器用户来说是一个可访问性问题。 http://www.bbc.co.uk/blogs/bbcinternet /2008/07/why_the_bbc_removed_microforma.html

The reason for this is to suppress the tooltip for microformatted date-times. The BBC dropped support for hCalendar because the appearane of the machine-readable date was an accessibility issue for those with cognitive disabilities aswell as some screen reader users. http://www.bbc.co.uk/blogs/bbcinternet/2008/07/why_the_bbc_removed_microforma.html

编辑:

我按照与Aron的建议相同的方式编写了一个jquery插件...

I whipped up a jquery plugin along the same lines as Aron's suggestion...

// uFsuppress plugin v1.0 - toggle microformatted dates
(function($){
$.ufsuppress = function() {
    $(".dtstart,.dtend,.bday").hover(function(){
        $(this).attr("ufdata",$(this).attr("title"));
        $(this).removeAttr("title");
    },function(){
        $(this).attr("title",$(this).attr("ufdata"));
        $(this).removeAttr("ufdata");
    });
}
})(jQuery);

// Usage
$.ufsuppress();


推荐答案

据我所知,它不是可以实际抑制显示标题标记。

As far as I know it is not possible to actually suppress showing the title tag.

但是有一些解决方法。

假设您想要保留链接和元素的title属性,可以使用Javascript删除 onmouseover()中的title属性并设置它再次在 onmouseout()

Assuming you mean you want to preserve the title property on your links and elements, you could use Javascript to remove the title property at onmouseover() and set it again at onmouseout().

// Suppress tooltip display for links that have the classname 'suppress'
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
    if (links[i].className == 'suppress') {
        links[i]._title = links[i].title;
        links[i].onmouseover = function() { 
            this.title = '';
        }
        links[i].onmouseout = function() { 
            this.title = this._title;
        }
    }
}

这篇关于在链接和&lt; abbr&gt;上禁用浏览器工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆