默认情况下,Chrome 浏览器操作提供了非常好的弹出效果。
已删除 ImageShack 图片链接已删除
关于如何使用 Firefox 扩展来近似这种效果的任何想法?有没有人成功实现类似这种效果?
谢谢。
最佳答案
对于像我这样刚开始使用第一个 Firefox 扩展的每个人,这里有一个示例代码:
yourextname\chrome\content\browser.xul
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://yourextname/skin/toolbar.css" type="text/css"?>
<overlay id="yourextname_overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<popupset>
<menupopup id="yourextname_menu_popup">
<menuitem label="Website" oncommand="gBrowser.selectedTab = gBrowser.addTab('http://www.your-website.com/');" />
<menuseparator />
<menuitem label="Options" oncommand="window.open('chrome://yourextname/content/options.xul', 'Options', 'dialog,chrome,modal,titlebar,toolbar,centerscreen=yes');" />
</menupopup>
<panel id="yourextname_popup" noautohide="false" noautofocus="true">
<label control="vvvname" value="Name:"/><textbox id="vvvname"/>
</panel>
</popupset>
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="yourextname_toolbar_button" class="toolbarbutton-1" context="yourextname_menu_popup" oncommand="document.getElementById('yourextname_popup').openPopup(document.getElementById('yourextname_toolbar_button'), 'after_start', 0, 0, false, false);" label="button name" tooltiptext="tooltip" />
</toolbarpalette>
</overlay>
yourextname\skin\toolbar.css
这将向工具栏按钮添加图标:
#yourextname_toolbar_button {
list-style-image:url(chrome://yourextname/skin/icon_024.png);
}
toolbar[iconsize="small"] #yourextname_toolbar_button {
list-style-image:url(chrome://yourextname/skin/icon_016.png);
}
yourextname\chrome.manifest
content yourextname chrome/content/
overlay chrome://browser/content/browser.xul chrome://yourextname/content/overlay.xul
skin yourextname classic/1.0 skin/
style chrome://global/content/customizeToolbar.xul chrome://yourextname/skin/toolbar.css
注意:确保将所有“yourextname”字符串替换为唯一的字符串,最好使用您的扩展名。
关于google-chrome - 在 Firefox 扩展中复制 Google Chrome 浏览器操作弹出效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2075697/