I’m working to my Extend Firefox 2 Runner Up winner Table2Clipboard.
Many users tell me to add a simple feature, exclude cells having style display: none.
The solution is so straightforward that I could not believe after initial implementation.
You can style an element using CSS selectors
<span id=“invisibleSpan” class=“invisible”>I’m invisible man</span>
or using the attribute style attribute
<span id=“invisibleSpan” style=“display : none”>I’m invisible man</span>
These two ways can both simply handled using getComputedStyle
var spanElement = document.getElementById(“invisibleSpan”);
var style = spanElement.ownerDocument.defaultView.getComputedStyle(spanElement, null);
var displayValue = style.getPropertyValue(“display”);
That’s all folks!!
Obviously you can use any CSS attribute not only display.
Pay attention to ownerDocument.defaultView, you should use window.getComputedStyle() but under XUL this doesn’t return what you expect.
getComputedStyle can be used in normal unprivileged HTML code, too.
getComputedStyle is a W3C standard and is present on Internet Explorer, Opera and Safari, too.
Little things make developer life easier.
Comments Off on How to get element style values from XUL (or HTML)
If you want to change the background color for HTML input text boxes you simply set the background-color style attribute, very obvious.
If you want to make same thing for XUL textboxes you apply the same style attribute discovering it doesn’t work… 😦
Ehm.. It works but you must disable standard mozilla behaviour using -moz-appearance attribute
Little lesson learned 😉
I wrote a little XBL component to allow menuitems to have images centered, I added it to Firefox 2 browser context menu and worked fine immediately, after a while I installed component on Firefox 3 beta 4 and surprisingly the menuitem didn’t show the image 😦
I’ve asked help on Mozilla IRC and after about an hour the mistery was revealed.
The innocent CSS declaration shown below works fine on Firefox 2
but requires a little modification on Firefox 3 beta 5pre (at this time the latest available)
You must notice the selector without !important attribute works on Firefox 3 when applied on menus different from browser context menu.
I suspect the browser context menu should have some special treatment on new Firefox…