reading CSS textdecoration

Giganews Newsgroups
Subject: reading CSS textdecoration
Posted by:  GoogleUsen…@2writers.com (Eddie)
Date: 13 Jul 2003

When I use JavaScript to read an element's textDecoration style, I
only get one value even if there are more than one in the sytle sheet.

For example if the text-decoration is defined as:
text-decoration : underline overline;

when reading element.currentStyle.textDecoration I only get
"underline"!!

What's worse is that element.style.textDecorationUnderline returns
"false"!!!

I have spent most of today researching this issue on the Internet and
cannot find out how to determine if multiple decorations are set for
an element.

Complete example:

<HTML><HEAD><TITLE>Test</TITLE>
<STYLE>
a.test :link {
  color : #00FF00;
  text-decoration : underline overline;
}    
</STYLE>
<SCRIPT language="JavaScript" type="text/JavaScript">
<!-- Begin
function bodyLoad() {
  var obj = document.getElementById('testLink');
  alert(obj.currentStyle.textDecoration);
  alert(obj.style.textDecorationUnderline);
}
//End -->
</SCRIPT>
</HEAD>
<BODY ONLOAD="bodyLoad()">
<A HREF="blank.htm" CLASS="test" ID="testLink">test</A>
</BODY></HTML>

Replies