日期:2014-05-17  浏览次数:20947 次

如何使导航单项点击时处于被选中状态??
<a href="main_usersetting.asp" style="text-decoration:none"><font color="#000000" class="font12" onmouseover="this.style.color='#6ba109'" onmouseout="this.style.color='#000000'">用户管理</font>

<a href="main_delist.asp" style="text-decoration:none"><font color="#000000" class="font12" onmouseover="this.style.color='#6ba109'" onmouseout="this.style.color='#000000'">部门管理</font>

我想让点击用户管理时候,在网页上导航用户管理保持当前状态,点击部门管理时候,网页就跳转到部门管理页面,导航部门管理保持当前状态,导航用户管理恢复到最初的样式。这个该怎么做呢??



------解决方案--------------------
你要好好学习css。不是全靠style控制。
这个问题涉及到class。一是可以ASP生成,二是可以由js控制。
------解决方案--------------------
VBScript code

'自制小函数
function list_on(pname,str)
if pname=str then
response.Write "<li class='on_bg'>"
else
response.Write "<li>"
end if
end function

用法:

class='on_bg'  这个CSS定义的on_bg 意思就是当前状态。如果你这都不会,那我就无言了


在页面顶部定义一个
pname
<%
pname="about1"

%>
这样的话,你用asp读出来以后就可以按照你说的那样显示了
<%
set aclass=server.CreateObject("adodb.recordset")
aclass.open "select * from case_fl order by px_id asc",conn,1,1
if aclass.eof and aclass.bof then
response.Write("&nbsp;暂无记录 !")
else
while not aclass.eof%>
<%call list_on(pname,"about"&aclass("id")&"")%><a href="/about/?id=<%=Caseclas("id")%> title="<%=aclass("title")%>"><%=aclass("title")%></a></li>
<%
aclass.movenext
wend
end if
aclass.close
set aclass=nothing
%>