Centril
Centril

Reputation: 2658

Access mozilla specific CSS property of #titlebar (chrome) "--chrome-background-color" in javascript

How do you access the value of the CSS property --chrome-background-color that is set on #titlebar of the Firefox chrome in an addon from javascript?

I tried the variants:

document.getElementById( 'titlebar' ).style.backgroundColor // undefined document.getElementById( 'titlebar' ).style['--chrome-background-color] // undefined

Upvotes: 1

Views: 252

Answers (1)

Centril
Centril

Reputation: 2658

This worked:

window.getComputedStyle( document.getElementById('titlebar') ).getPropertyValue( '--chrome-background-color' )

From: Get a CSS value with JavaScript

Lesson: don't be hasty + it works for mozilla specific chrome elements.

Upvotes: 2

Related Questions