Firefox userChrome.css window focus selector

1.1k Views Asked by At

Is there a CSS selector I can use in userChrome.css to change the text color of Firefox when the whole browser window loses focus?

I've tried:

window:focus element { color: #aaa; }    /* does nothing */
window:active element { color: #aaa; }   /* only when something's being clicked */
window:hover element { color: #aaa; }    /* only when the cursor is over the window */
window[focus] element { color: #aaa; }   /* wishful thinking--doesn't work */
window[active="true"] element { color: #aaa; }   /* documented to work... */

Or am I stuck using Javascript? If so, is there a userChrome.js that I can put that script in?

1

There are 1 best solutions below

1
Robin On

Solved!

Per https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-window-inactive, this functionality has been changed.

Now you can use:

element:-moz-window-inactive { color: #aaa; }

and:

element:not(-moz-window-inactive) { color: #aaa; }

To change CSS styles depending on if the Firefox window is focused.