<table id="table1" style="background-color:#ffcc66"></table>
<script>
alert(document.all.table1.style.backgroundColor);
</script>

解决方案 »

  1.   

    <HTML> 
    <HEAD> 
    <TITLE>颜色选取器</TITLE> 
    <META content="text/html; charset=gb2312" http-equiv=Content-Type> 
    <STYLE type=text/css>TD { 
    FONT-SIZE: 10.8pt 

    BODY { 
    FONT-SIZE: 10.8pt 

    BUTTON { 
    WIDTH: 5em 

    </STYLE> 
    <SCRIPT language=JavaScript> 
    var SelRGB = ''; 
    function EndColor() {
     ShowColor.bgColor = SelRGB; 

    </SCRIPT> <SCRIPT event=onclick for=ColorTable language=JavaScript> 
     SelRGB = event.srcElement.bgColor; 
     EndColor(); 
    </SCRIPT> <META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD> 
    <body ><font style="font-size:12pt" color=green>&nbsp; </font> 
    <table width="136" height="136" border="0" align="center" cellPadding=0 cellspacing=0 id=ColorTable style="CURSOR: hand">
      <tr> 
        <td width="34" height="34" bgcolor="yellow">&nbsp; </td>
        <td width="34" height="34" bgcolor="green"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="lime"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="aqua"> <div align="center"></div></td>
      </tr>
      <tr> 
        <td width="34" height="34" bgcolor="silver"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="fuchsia"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="olive"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="teal"> <div align="center"></div></td>
      </tr>
      <tr> 
        <td width="34" height="34" bgcolor="gray"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="red"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="white"> <div align="center"></div></td>
        <td bgcolor="blue"> <div align="center"></div></td>
      </tr>
      <tr> 
        <td width="34" height="34" bgcolor="black"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="maroon"> <div align="center"></div></td>
        <td width="34" height="34" bgcolor="purple"> <div align="center"></div></td>
        <td bgcolor="navy"> <div align="center"></div></td>
      </tr>
    </table>
    <TABLE width="181" border=0 align="center" cellPadding=0 cellSpacing=0>
      <TBODY>
        <TR>
          <TD width="10">&nbsp;</TD>
          <TD width="177"><div align="center"><font color="#0000FF"> 选取颜色</font> </div>
            <TABLE    width=34 height=34 border=1 align="center" cellPadding=0 cellSpacing=0 id=ShowColor>
              <TBODY>
                <TR> 
                  <TD></TD>
                </TR>
              </TBODY>
            </TABLE>
            <div align="left"> </div></TD>
        </TR>
      </TBODY>
    </TABLE>
    <p>&nbsp;</p>
    </body>
    </html>