问题描述
我已经做了完整的FF扩展,并在URL栏中有一个按钮。老板现在希望按钮显示一个特定的字符串时,你把鼠标悬停在上面。这里是我当前的按钮代码:
$ p $ var $ load $ url $ function $ $ $ $ var 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);
返回btn;
var doc = require('sdk / window / utils')。getMostRecentBrowserWindow()。document;
var urlbarButton = loadURLButton(doc,openTab);
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:
我可以添加些什么来使某个id弹出悬停?
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);
推荐答案
该属性不是工具提示,但它是tooltiptext!所以只是做btn.setAttribute('tooltiptext','你想要什么');
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按钮在悬停时显示一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!