如何使 Firefox 扩展 URL 按钮在悬停时显示字符串 [英] How to make a Firefox Extension URL Button show a string when hovered over
本文介绍了如何使 Firefox 扩展 URL 按钮在悬停时显示字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经制作了完整的 FF 扩展,并且 URL 栏中有一个按钮.当您将鼠标悬停在按钮上时,boss 现在希望按钮显示某个字符串.这是我当前的按钮代码:
I have made my full FF extension, and there is a button in the URL bar. The boss now wants the button to show a certain string when you hover over it. Here is my current code for the button:
var loadURLButton = function(doc, urlBtnClick) {
var urlBarIcons = doc.getElementById('urlbar-icons')
var btn = doc.createElement('toolbarbutton');
btn.setAttribute('id', 'urlbutton');
btn.setAttribute('image', require('sdk/self').data.url("canNone.png"));
btn.addEventListener('command', urlBtnClick, false);
urlBarIcons.appendChild(btn);
return btn;
}
var doc = require('sdk/window/utils').getMostRecentBrowserWindow().document;
var urlbarButton = loadURLButton(doc, openTab);
为了在悬停时弹出一些 id,我可以添加什么?
What can I add to this in order to make some id pop up on hover?
推荐答案
哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇该属性不是工具提示而是工具提示文本!所以就做 btn.setAttribute('tooltiptext', 'whatever you want');
Awwwww man all that work for nothing. The attribute is not tooltip but it is tooltiptext! So just do btn.setAttribute('tooltiptext', 'what ever you want');
var loadURLButton = function(doc, urlBtnClick) {
var urlBarIcons = doc.getElementById('urlbar-icons')
var btn = doc.createElement('toolbarbutton');
btn.setAttribute('id', 'urlbutton');
btn.setAttribute('tooltiptext', 'mytt');
btn.setAttribute('image', 'chrome://branding/content/icon32.png');
btn.addEventListener('command', urlBtnClick, false);
urlBarIcons.appendChild(btn);
return btn;
}
var doc = document;
var urlbarButton = loadURLButton(doc, null);
这篇关于如何使 Firefox 扩展 URL 按钮在悬停时显示字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文