简体   繁体   English

如何在firefox扩展中更改statusbarpanel背景颜色

[英]How to change statusbarpanel background color in firefox extension

I'm writing a firefox extension which displays a statusbarpanel containing some text. 我正在编写一个firefox扩展,它显示包含一些文本的statusbarpanel。 I want to change the background color of my statusbarpanel depending on the message. 我想根据消息更改statusbarpanel的背景颜色。 eg red background for errors. 例如红色背景表示错误。

var pnl = document.getElementById("panelId");
pnl.label = "OK";
pnl.style.color = "white";
pnl.style.backgroundColor = "green";

All of the above code works except for the last line, which causes no change. 以上所有代码均有效,但最后一行除外,这不会引起任何变化。 The actual value of the property changes, but the statusbarpanel still shows the default status bar color. 该属性的实际值会更改,但是statusbarpanel仍显示默认状态栏颜色。 I also tried background instead of backgroundColor but that doesn't help. 我也尝试了background而不是backgroundColor但这没有帮助。

尝试将-moz-appearance CSS属性设置为'none''none !important'

Like the previous solution but only using javascript : 像以前的解决方案一样,但只使用javascript:

var pnl = document.getElementById("panelId");
pnl.label = "OK";
pnl.style.color = "white";
pnl.style.backgroundColor = "green";
pnl.style.MozAppearance = "none"

Note that after you do this you'll pretty much have to style it from scratch again and it will probably also lose it's OS specific style. 请注意,执行完此操作后,您几乎必须重新从头开始对其进行样式设置,并且可能还会丢失其特定于操作系统的样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM