views:

71

answers:

1

What's a good workaround to this IE bug that would still allow me to set the display style of an HTML element to 'inherit' in IE7 or IE6 using javascript?

    var el = document.getElementById('someElementID');
    if (!el) return false;
    try {
        var displayValue = 'inherit';
        //the next line throws exception in IE7 and IE6
        // when displayValue = 'inherit'
        // but not for other legit values like 'none', 'block', 'inline' or even ''
        el.style['display'] = displayValue;
    } catch (e) {
        alert(e.message);
    }

Assume that I don't want to set visible: hidden, position:absolute it out of view or z-index it under something else.

+3  A: 

A lot of values for the display property was added in CSS 2, and inherit is one of them. Older browsers don't support these new values. You can compare the possible values in CSS 1 and CSS 2.

Even if you could set the value, it's useless as the browser doesn't know what to do with it.

Guffa
jimben