日期:2014-05-16 浏览次数:20346 次
<ul class="nav" id="nav">
<li class="home"><a href="xx.html">首页</a></li>
<li class="f1"><a href="xx.html?tag=f1">分类1</a></li>
<li class="f2"><a href="xx.html?tag=f2">分类2</a></li>
<li class="f3"><a href="xx.html?tag=f3">分类3</a></li>
<li class="f4"><a href="xx.html?tag=f4">分类4</a></li>
</ul>
<script>
var search = location.search//////////
var as = document.getElementById('nav').getElementsByTagName('a');
if (search != '') {
for (var i = 0; i < as.length; i++)
if (as[i].href.indexOf(search) != -1) {//连接包含当前页面名称则设置获得焦点
as[i].className = 'focus'; break;
}
}
else as[0].className = 'focus'; //没有参数怎默认首页
</script>
var search = /tag=[^&]+/i.exec(location.search);
if (search) search = search[0];
var as = document.getElementById('nav').getElementsByTagName('a');
if (search) {
for (var i = 0; i < as.length; i++)
if (as[i].href.indexOf(search) != -1) {//连接包含当前页面名称则设置获得焦点
as[i].className = 'focus'; break;
}
}
else as[0].className = 'focus'; //没有参数怎默认首页