Snippets code from my daily experience

April 7, 2008

How to get element style values from XUL (or HTML)

Filed under: css, table2clipboard, xul — dafi @ 8:15 pm

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

.invisible {
display: none;
}

<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.

April 5, 2008

Houston we have a problem: ViewSourceWith under FF3b5

Filed under: firefox, viewsourcewith — dafi @ 10:46 am

Bad news for ViewSourceWith and its compatibility with FF3.0.

Due to the bug “Code running in context of hiddenDOMWindow runs unprivileged?” ViewSourceWith stopped to work when FF3.0b5 was published.

I’ve done many code modifications to adhere to FF3 requirements and now VSW 0.1b is ready.
After dozen of regression tests I’m afraid something is missed so I ask to VSW users to help me to test it deeper.

Any help is welcomed not only technical tests, for example you can share my help request in other blogs/forums.
If you would help me to test VSW 0.1 download it from here.

Tests can be done on

  • Firefox from 2.0 to 3.0b5
  • SeaMonkey
  • Songbird
  • Flock

Tests must verify

  • text box editing
  • page view source
  • css/js view
  • error console view source clicking on links
  • temp files removal at application exit

Try to

  • open more that one browser window closing the openers and verify if VSW continues to work
  • use your daily VSW usage behaviour
  • use you creativity ;)

Platforms

  • Windows
  • Linux (I use Ubuntu Feisty)
  • MacOSX

Please use this post to give me feedback or better land to “ViewSourceWith Open Discussion

Blog at WordPress.com.