Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Cannot assign value to CSS display property

9 views
Skip to first unread message

Nathan Sokalski

unread,
Aug 31, 2009, 6:38:29 PM8/31/09
to
I have an eventhandler that I want to use to modify the style properties of
an element. Here is my current code:

function ShowSubmenu(evt)
{
e=window.event||evt;
var submenu=document.getElementById(e.srcElement.submenuid);
window.alert(submenu.style.display);
submenu.style.display='table';
}

The window.alert successfully shows the current value of the CSS display
property, but when I attempt to assign a new value to it I recieve the
following error:

"Could not get the display property. Invalid argument."

What is the problem here? Any help would be appreciated. Thanks.
--
Nathan Sokalski
njsok...@hotmail.com
http://www.nathansokalski.com/


Martin Honnen

unread,
Sep 1, 2009, 7:46:01 AM9/1/09
to
Nathan Sokalski wrote:
> I have an eventhandler that I want to use to modify the style properties of
> an element. Here is my current code:
>
> function ShowSubmenu(evt)
> {
> e=window.event||evt;
> var submenu=document.getElementById(e.srcElement.submenuid);
> window.alert(submenu.style.display);
> submenu.style.display='table';
> }
>
> The window.alert successfully shows the current value of the CSS display
> property, but when I attempt to assign a new value to it I recieve the
> following error:
>
> "Could not get the display property. Invalid argument."
>
> What is the problem here? Any help would be appreciated. Thanks.

Which browser is that? I think IE before IE 8 does not know the display
value 'table':
http://msdn.microsoft.com/en-us/library/ms530751(VS.85).aspx

A workaround for such problems is usually simply to let the browser
choose the default it has e.g. if you have
<table id="t1" style="display: none;">...</table>
then setting e.g.
document.getElementById('t1').style.display = '';
will erase the inline style for display and that way the browser simply
uses the value defined in its browser stylesheet for that element.


--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

0 new messages