读书人

Js代码无法在火狐运行,该怎么处理

发布时间: 2012-03-31 13:13:26 作者: rapoo

Js代码无法在火狐运行
<script language=javascript>
function seleboard(n)
{
for(i=0;i<document.getElementById("seletable").cells.length;i++)
document.getElementById("seletable").cells[i].className="sele1";
document.getElementById("seletable").cells[n].className="sele2";
for(i=0;i<document.getElementById("maintable").tBodies.length;i++)
document.getElementById("maintable").tBodies[i].style.display="none";
document.getElementById("maintable").tBodies[n].style.display="block";
}
</script>

在IE可以

[解决办法]
cells这个属性,Firefox不能在table下用,在tr下用就有。
[解决办法]

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>demo</title><style type="text/css"><!--body,td,th {font-family: Arial, Helvetica, sans-serif;font-size: 12px;}body {margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;}a:link {color: #000000;text-decoration: underline;}a:visited {text-decoration: underline;color: #000000;}a:hover {text-decoration: none;}a:active {text-decoration: underline;}#container{    margin-left:auto;margin-right:auto;width:1066px;;}#left{    margin-top:20px;    margin-left:40px;    width:710px;float:left;clear:right; }#up{    margin:0px;width:684px;height:264px;}.sec1 {  background:transparent  #FFFFFF no-repeat 0px 0em;  cursor: pointer;  color: #000000;  font-weight: bold;  height:40px;  font-size:16px;  }.sec2 {  background:transparent #66CCFF no-repeat 0px 0em;  cursor: pointer;  color: #FF0000;  font-weight: bold;  height:40px;  font-size:16px;  }.main_tab {  background-color:#FFFF33;  position:inherit;}.STYLE3 {font-size: 10px; color: #666666; }--></style><script language=javascript>function secBoard(n){for(i=0;i<document.getElementById('secTable').rows[0].cells.length;i++){document.getElementById('secTable').rows[0].cells[i].className="sec2";document.getElementById('secTable').rows[0].cells[n].className="sec1";}for(i=0;i<document.getElementById('mainTable').tBodies.length;i++){document.getElementById('mainTable').tBodies[i].style.display="none";}document.getElementById('mainTable').tBodies[n].style.display="block";}</script></head><body><div id="container">     <div id="left">               <div id="up">               <table width="516px" height="40px;" border=0 cellpadding=0 cellspacing=0 id=secTable>           <tr align=center>                       <td width="258px" valign="middle"  class=sec1 onclick="secBoard(0)">Find a business</td>                      <td width="258px" valign="middle" class=sec2 onclick="secBoard(1)">Add your buisiness</td>            </tr>           </table>           <table width="685px" height="224px"  border="0"  cellpadding="o" cellspacing="0" class="main_tab" id="mainTable">            <form action="" method="post" name="find_business" id="find_business">              <tbody style="display:block;">               <tr><td>1111111111111111111111</td></tr>              </tbody>            </form>            <tbody style="display:none;">              <tr>                <td align="center" valign="top"><br />                  2222222222 </td>              </tr>            </tbody>          </table>       </div>      </div></div></body></html> 

读书人网 >JavaScript

热点推荐