一个ASP写的侧边菜单栏
2008-02-23 09:38:32来源:互联网 阅读 ()
同于工作的必要,无意之中写出了一个ASP的侧边的菜单栏类。代码如下:
<%
class menus
Public Title, ID, Image, TitleColor, Target, Background, HeadImage, Height, Width, Bgcolor, Style
Private menuItem, menuStr
Private Sub Class_Initialize
Title = ""
ID = ""
menuItem = ""
Image=""
TitleColor = "#000000"
Target = "_blank"
Background = ""
HeadImage = ""
Height = "20"
Width = "100%"
Bgcolor = ""
Style = ""
script
End Sub
Private Sub Class_Terminate
Title = ""
ID = ""
menuItem = ""
End Sub
Public Function AddItem(Byval nItem, Byval nURL)
menuItem = menuItem & "<tr><td style='font-size:12px;' align='left'> {$Image}<a href='" & nURL & "' target='"&Target&"' class='"& Style &"'>" & nItem & "</a></td></tr>"
End Function
Public Sub Show()
menuStr = "<table border=0 width='"& Width &"' style='border:1px solid #999999;' bgcolor='"& Bgcolor &"'><tr><td height='"& Height &"' Onclick=menus('" & ID & "') bgcolor='"& Bgcolor &"' valign='bottom' style='" & _
"font-size:12px;color:"&TitleColor&";cursor: hand;' background='"&Background&"' align='left'> {$HeadImage}" & Title & "</td></tr></table><div id=" & chr(34) & ID & chr(34) & " style=" &chr(34) & _
"display:none;"& chr(34) & "><table width=100% border=0 style='border-left:1px solid #999999;border-right:1px solid #999999;border-bottom:1px solid #999999;'>" & menuItem & "</table></div>"
if Image<>"" then
menuStr = replace(menuStr, "{$Image}", Image)
else
menuStr = replace(menuStr, "{$Image}", "")
end if
if HeadImage<>"" then
menuStr = replace(menuStr, "{$HeadImage}", HeadImage)
else
menuStr = replace(menuStr, "{$HeadImage}", "")
end if
Response.Write menuStr
End Sub
Private Function script()
Dim JScript
JScript = "<script language="&chr(34)&"JavaScript"&chr(34)&"type="&chr(34)&"text/JavaScript"&chr(34)& _
">"&vbcrlf&"<!--"&vbcrlf&"function menus(str){"&vbcrlf&"var obj;if (document.getElementById(str)){"&vbcrlf& _
"obj=document.getElementById(str);"& _
"if (obj.style.display =="&chr(34)&"none"&chr(34)&"){obj.style.display ="&chr(34)&chr(34)& _
";}else{obj.style.display ="&chr(34)&"none"&chr(34)&";}}}//--></script>"
response.Write JScript
End Function
Public Sub AddNew()
Title = ""
ID = ""
menuItem = ""
menuStr = ""
End Sub
Public Sub OpenItem(Byval ItemID)
End Sub
end class
%>
使用方法:
<%
Dim NewMenus
Set NewMenus = new menus
NewMenus.Target = "" '打开方式
NewMenus.Bgcolor = "#336699" '主标签背景色
NewMenus.TitleColor = "#FFFFFF" '主标签字体颜色
NewMenus.Height = "10px" '高度
NewMenus.Style ="a1" '子标签样式
NewMenus.Width = "100%" '菜单宽度
NewMenus.AddNew
NewMenus.Title = "门户网站"
NewMenus.ID = "menu1"
NewMenus.AddItem "网易", "http://www.163.com"
NewMenus.AddItem "搜狐", "http://www.sohu.com"
NewMenus.Show
NewMenus.AddNew
NewMenus.Title = "个人网站"
NewMenus.ID = "menu2"
NewMenus.AddItem "IEBSoft studio", "http://iebsoft.512j.com"
NewMenus.AddItem "租用的空间", "http://107814.hxidc.com"
NewMenus.Show
NewMenus.AddNew
NewMenus.Title = "网站新闻管理"
NewMenus.ID = "menu3"
NewMenus.AddItem "新闻列表", "#"
NewMenus.AddItem "图片新闻", "#"
NewMenus.AddItem "新闻管理", "#"
NewMenus.Show
Set NewMenus = Nothing
%>
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash