火狐中的标题属性

Title attribute in Firefox

本文关键字:属性 标题 火狐      更新时间:2023-09-26

如果在 Firefox 中查看,特定 HTML 元素上的 title 属性不会显示在我的应用程序中。有多个主题可以解释此问题。我无法找到适合我需求的解决方案。所以我问你能不能帮忙。

我有很多div排队。将鼠标悬停在div 上时,每个div 都应显示不同的值(标题)。标题属性在Chrome中工作正常,但我需要一些类似Firefox的东西。

title 属性是从 Javascript 动态设置的!

我的Javascript:

dojo.connect(div, 'mousemove',rasterTimeDisplay);
function rasterTimeDisplay() {
dojo.attr(evt.target, 'title', "some new title");
 }

为什么不存储要显示在另一个属性中的数据?因为你使用javascript来提供你的数据存储属性,所以你可以随心所欲。

例如,使用 jQuery:

//I feed my data-storage attribute
$("#my_div").attr('my-data', '<h1>my content to be displayed</h1>');
//And then i bind the hover event to toggle displaying of this data
$("#my_div").hover(
    function(){
        $(this).html($(this).attr('my-data'));
    },
    function(){
        $(this).html('');
    }
);

或者使用标准 JavaScript :

document.getElementById('my_div').my_data = '<h1>my content to be displayed</h1>';
document.getElementById('my_div').onmouseover = function(){
    this.innerHTML = this.my_data;
};
document.getElementById('my_div').onmouseoout = function(){
    this.innerHTML = '';
};

对不起,如果我误会你了。但是,您正在尝试在悬停时触发title属性?但是 title 属性已经默认由悬停触发:

因此,如果您只是将属性添加到所需的元素中,您将获得有关悬停的额外信息。

var titles = document.getElementsByClassName('title');
for(var i = 0; i < titles.length; i++)
{
    titles[i].title = 'Hover information ' + i;
}

js小提琴

我对jQuery方式感兴趣:

$('.title').attr('title', 'Hover information');

还是不行?

步骤1:首先尝试在安全模式下运行您的火狐客户端。您的问题现在可能已解决。如果是这种情况,请继续执行步骤 2。还。。。好吧,我建议您更新您的 grapical 驱动程序或安装更新的版本。

步骤2:禁用硬件加速(AH)。

在这里查看另一个答案:https://support.mozilla.org/nl/questions/860902

<小时 />现在,如果您只是想解决一下,甚至可以让最古老的Firefox浏览器支持此功能。你可以在这里找到一个:工具提示(title="...")不会显示在火狐中

<小时 />

我希望这解决了你的问题。