Re: setting css property to empty string from script

On Fri, Mar 6, 2009 at 8:50 AM, Mike Wilson <mikewse@hotmail.com> wrote:
> When you have overrided the value of an element's CSS attribute
> through script, then you can reset the attribute back to the
> value governed by style declarations by assigning the empty
> string. Example (see *):
>
>  <style type='text/css'>
>    span {border: 1px solid red}
>  </style>
>  <span id=myspan>lorem ipsum</span>
>
>  e = document.getElementById("myspan");
>  window.getComputedStyle(e,"").borderLeftWidth
>  -> "1px"
>

Nonstandard. Some implementations may treat window as a reference to
document.defaultView, but window is not guaranteed to be
document.defaultView.

Try it in Safari 2, for example.

>  e.style.borderLeftWidth = 2;
>  window.getComputedStyle(e,"").borderLeftWidth
>  -> "2px"
>

Nonstandard. Use a unit. Use a string value. Dom setters that are
standardized to take domstring should take a domstring. Assigning a
number is nonstandard and does not work consistently.

Garrett

Received on Friday, 6 March 2009 22:11:48 UTC