<title>无标题文档</title>
<script>
var buttonMap={
   "/index.asp":1,                       这里声明变量为什么要带上:1
   "/about.html":2,
   "/news.asp":3,
   "/products.asp":4
   }
window.attachEvent("onload",function(){
   for(var s in buttonMap) 
if(location.href.indexOf(s)>0){                  这里查找到的值是什么,如果URL是http://127.0.0.1/about.html
   oTopNav.cells[1].id="bg1";                   cells[1].这个值是什么意思
   
   oTopNav.cells[buttonMap[s]].id="bg2";           cells[buttonMap[s]].这个值是多少
   break;
   }
   });
   </script>
<style type="text/css">
#bg1{
font-weight:bold;
font:Arial, Helvetica, sans-serif;
}
#bg2{
font-weight:bold;
font:Arial, Helvetica, sans-serif;
}
#bg1 a:link, #bg1 a:visited {
       color: #FF9900;
       text-decoration: none
}
#bg1 a:hover, #bg1 a:active {
       color: #33FF99;
       text-decoration: none;
}
#bg2 a:link, #bg2 a:visited {
       color: #66CCFF;
       text-decoration: none;
}
</style></head>
<body>
<br />
<table width="500" height="17" border="0" cellpadding="0" cellspacing="0" id="oTopNav">
   <tr>
   <td></td>
<td width="75" align="center" valign="middle" id="bg1" ><a href="index.asp">Home</a></td>
<td width="75" align="center" valign="middle" id="bg1" ><a href="about.html">About</a></td>
<td width="75" align="center" valign="middle" id="bg1" ><a href="news.asp">News</a></td>
<td width="75" align="center" valign="middle" id="bg1" ><a href="products.asp">Products</a></td>
<td width="200"></td>
   </tr>
</table>
</body>
</html>

解决方案 »

  1.   

    var buttonMap={------一个对象,多个属性,json格式的
      "/index.asp":1, 这里声明变量为什么要带上:1
      "/about.html":2,
      "/news.asp":3,
      "/products.asp":4
      }
    window.attachEvent("onload",function(){
      for(var s in buttonMap) 
    if(location.href.indexOf(s)>0){ 这里查找到的值是什么,如果URL是http://127.0.0.1/about.html
    location.href中查找/index.asp,/about.html,/news.asp,/products.asp,所以如果URL是http://127.0.0.1/about.html 找到到   "/about.html":2,
      oTopNav.cells[1].id="bg1"; cells[1].这个值是什么意思table 的第一个单元格,通过table ID去
       
      oTopNav.cells[buttonMap[s]].id="bg2"; cells[buttonMap[s]].这个值是多少buttonMap[s]=2
      break;
      }
      });
      </script>