1

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?

brandizzi
  • 26,083
  • 8
  • 103
  • 158
Robbie Wxyz
  • 7,671
  • 2
  • 32
  • 47
  • If `:focus` doesnt work try `:active` and also try `:hover` the `[focus]` wont work because i dont see an attribute changing as the browser is focused or not. – Noitidart Mar 16 '15 at 23:04
  • @Noitidart: Thanks for your interest in my question. `:active` checks if anything is being clicked on. `:hover` checks if the mouse is inside the window. `[focus]` was just wishful thinking. Do you know of a way to easily add some JS the way you do CSS with `userChrome.css`? – Robbie Wxyz Mar 16 '15 at 23:11
  • 1
    According to https://developer.mozilla.org/en-US/Add-ons/Themes/Obsolete/Theme_changes_in_Firefox_3.5#Supporting_3.5_Features, `[active="true"]` should work...but it doesn't. – Robbie Wxyz Mar 16 '15 at 23:32
  • 1
    Ahah! It's changed: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-window-inactive . Now it's `:-moz-window-inactive`. – Robbie Wxyz Mar 16 '15 at 23:40
  • So the change was post Firefox 3.5 right? So it's safe to use `-moz-window-inactive` if I want to target Firefox 4+? – Noitidart Mar 17 '15 at 01:44

1 Answers1

2

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.

Robbie Wxyz
  • 7,671
  • 2
  • 32
  • 47