复制代码 代码如下:
<%
rem文章标题:利用vbs类实现css按钮
rem作者:yanek
rem联系:aspboy@263.net
ClassCssButton
PublicName
PublicBackColor
PublicBorderColor
PublicFont
PublicFontColor
PublicWidth
PublicText
PublicUrl
PublicMouseOverColor
PublicFunctionGenerateStyleTag()
'CreatetheSTYLEtag
DimstrStyle
strStyle="<STYLETYPE=""text/css"">"&vbCrLf&_
"<>"&vbCrLf&_
"</STYLE>"
GenerateStyleTag=strStyle
EndFunction
PublicFunctionGenerateButtonTag()
DimstrHTML
strHTML="<ahref="""&Url&"""class=""buttontext"&Name&""""&_
"onMouseOver=""this.className='buttonover"&Name&"';"""&_
"onMouseOut=""this.className='buttontext"&Name&"';"">"&_
vbCrLf&"<divid=""mybutton"&Name&""">"&vbCrLf&Text&vbCrLf&"</div></a>"&vbCrLf
GenerateButtonTag=strHTML
EndFunction
EndClass
rem建立类的实例
DimbtnYahoo,btnLycos
SetbtnYahoo=NewCssButton
SetbtnLycos=NewCssButton
rem设置按钮对象的相关属性
btnYahoo.BackColor="#aaaaaa"
btnYahoo.BorderColor="#bbbbbb"
btnYahoo.Font="bold12ptVerdana"
btnYahoo.FontColor="black"
btnYahoo.Width="80px"
btnYahoo.MouseOverColor="yellow"
btnYahoo.Url="http://www.yahoo.com/"
btnYahoo.Name="yahoo"
btnYahoo.Text="Yahoo!"
rem调用方法输出按钮
Response.WritebtnYahoo.GenerateStyleTag()
Response.WritebtnYahoo.GenerateButtonTag()
Response.Write"<p></p>"
rem设置按钮对象的相关属性
btnLycos.BackColor="#aaaaaa"
btnLycos.BorderColor="#bbbbbb"
btnLycos.Font="10ptArial"
btnLycos.FontColor="black"
btnLycos.Width="70px"
btnLycos.MouseOverColor="yellow"
btnLycos.Url="http://www.lycos.com/"
btnLycos.Name="lycos"
btnLycos.Text="Lycos"
rem调用方法输出按钮
Response.WritebtnLycos.GenerateStyleTag()
Response.WritebtnLycos.GenerateButtonTag()
%>
演示:http://www.cnaspol.com/vbsclasscssbutton.asp