JavaScript Tutorial/Document/fgColor

Материал из Web эксперт
Перейти к: навигация, поиск

document.fgColor

The fgColor property specifies the default text color.

This is equivalent to assigning the color to the text attribute in the <body> tag.

The color is expressed as a string in hexadecimal digits or as one of the JavaScript standard color names.

The hexadecimal form is made up of 6 digits that follow the pattern "RRGGBB."



<HTML>
<head>
<title>this is a title</title>
</head>
<BODY bgcolor="beige" text= "black" link="darkblue" vlink="honeydew">
<SCRIPT language="JavaScript">
<!--
document.write("The text color is "+document.fgColor+"<BR>");
//-->
</SCRIPT>
</BODY>
</HTML>


Set the document.fgColor (IE)

<html>
    <script language="JavaScript">
    <!--
    document.fgColor="0000ff";
    -->
    </script>
    <body>
    The color of all text on this page is blue.
    </body>
    </html>