利用vbs类实现css按钮的代码
程序员文章站
2022-03-20 13:59:27
复制代码 代码如下:<% rem 文章标题: 利用vbs类实现css按钮 rem 作者:yanek ...
复制代码 代码如下:
<%
rem 文章标题: 利用vbs类实现css按钮
rem 作者:yanek
rem 联系:aspboy@263.net
class cssbutton
public name
public backcolor
public bordercolor
public font
public fontcolor
public width
public text
public url
public mouseovercolor
public function generatestyletag()
'create the style tag
dim strstyle
strstyle = "<style type=""text/css"">" & vbcrlf & _
"<!--" & vbcrlf & _
"#mybutton" & name & " {border-style: inset; " & vbcrlf & _
" border-color: " & bordercolor & ";" & vbcrlf & _
" background-color: " & backcolor & ";" & vbcrlf & _
" width: " & width & ";" & vbcrlf & _
" text-align: center; }" & vbcrlf & vbcrlf & vbcrlf & _
"a.buttontext" & name & " {color: " & fontcolor & "; " & vbcrlf & _
" text-decoration: none; " & vbcrlf & _
" font: " & font & ";" & vbcrlf & _
" cursor: hand; }" & vbcrlf & vbcrlf & vbcrlf & _
".buttonover" & name & " {color: " & mouseovercolor & ";" & vbcrlf & _
" text-decoration: none; " & vbcrlf & _
" font: " & font & ";" & vbcrlf & _
" cursor: hand; }" & vbcrlf & _
" // -->" & vbcrlf & _
"</style>"
generatestyletag = strstyle
end function
public function generatebuttontag()
dim strhtml
strhtml = "<a href=""" & url & """ class=""buttontext" & name & """ " & _
"onmouseover=""this.classname='buttonover" & name & "';"" " & _
"onmouseout=""this.classname='buttontext" & name & "';"">" & _
vbcrlf & "<div id=""mybutton" & name & """>" & vbcrlf & text & vbcrlf & "</div></a>" & vbcrlf
generatebuttontag = strhtml
end function
end class
rem 建立类的实例
dim btnyahoo, btnlycos
set btnyahoo = new cssbutton
set btnlycos = new cssbutton
rem 设置按钮对象的相关属性
btnyahoo.backcolor = "#aaaaaa"
btnyahoo.bordercolor = "#bbbbbb"
btnyahoo.font = "bold 12pt verdana"
btnyahoo.fontcolor = "black"
btnyahoo.width = "80px"
btnyahoo.mouseovercolor = "yellow"
btnyahoo.url = "http://www.yahoo.com/"
btnyahoo.name = "yahoo"
btnyahoo.text = "yahoo!"
rem 调用方法输出按钮
response.write btnyahoo.generatestyletag()
response.write btnyahoo.generatebuttontag()
response.write "<p> </p>"
rem 设置按钮对象的相关属性
btnlycos.backcolor = "#aaaaaa"
btnlycos.bordercolor = "#bbbbbb"
btnlycos.font = "10pt arial"
btnlycos.fontcolor = "black"
btnlycos.width = "70px"
btnlycos.mouseovercolor = "yellow"
btnlycos.url = "http://www.lycos.com/"
btnlycos.name = "lycos"
btnlycos.text = "lycos"
rem 调用方法输出按钮
response.write btnlycos.generatestyletag()
response.write btnlycos.generatebuttontag()
%>
演示:http://www.cnaspol.com/vbsclasscssbutton.asp
上一篇: 创建Guid 的代码