让你的链接动起来
点击次数:30 次 发布日期:2008-11-26 22:59:44 作者:源代码网
|
源代码网推荐
This is the first link!
This is the second link!
This is the third link!
This is the forth link!
在<marquee>标记中有一个属性direction,如果将他的值赋为"up"或"down",那么就会产生字幕的效果,根据这个特性我们就能使超级联接“动”起来。但如果我们的浏览器不是IE4.0或更高版本的话,就不能产生这个效果,所以必须考虑这一情况。本例采用了VBScript,夹在“<!--”和“-->”之间的代码被传送到客户端并在客户端的机器上执行。源代码如下: <HTML> <head><title>Active HyperLink</title></head> <body> <SCRIPT language="VBScript"> <!-- sign="no" sign是判断浏览器是不是IE4.0或更高版本的标记 browserName = navigator.appName 获得浏览器的名称 browserVer = Cint(String(1,navigator.appVersion)) 获得浏览器的版本并将其转化为整型
If (browserName = "Microsoft Internet Explorer" and browserVer >= 4 ) Then sign="ok" 当浏览器是IE4.0或更高版本,sign="ok" Function marqueeStart() 函数marqueeStart()的作用是当sign="ok"时创建<marquee>及其属性 If sign="ok" Then Document.write ("<marquee id=mymarquee behavior=scroll direction=up width=400 height=100 scrollamount=1 scrolldelay=500 onmouseover=mymarquee.stop() onmouseout=mymarquee.start()>") onmouseover=‘mymarquee.stop()’和onmouseout=‘mymarquee.start()’语句表示当鼠标移进或移出时字幕停止或卷动,scrollamount和scrolldelay分别表示字幕移动的速度和间隔 End If End Function
F tion marqueeEnd() 函数marqueeEnd()的作用是当sign="ok"时创建</marquee> If sign="ok" Then Document.write ("</marquee>") End If End Function --> </SCRIPT>
<div align="center"> <!--为了美观建立一个表格,将字幕放入表格单元中--> <center> <table border="1" width="400" bordercolor="#FF0000" height="100"> <tr> <td width="100%"> <SCRIPT language="VBScript"> 调用marqueeStart函数 <!-- marqueeStart --> </SCRIPT>
<p><a href="http:1">This is the first link!</a></p> <p><a href="http:2">This is the second link!</a></p> <p><a href="http:3">This is the third link!</a></p> <p><a href="http:4">This is the forth link!</a></p> <!--当浏览器不是IE4.0或更高版本时只会产生静态效果 -->
<SCRIPT language="VBScript"> 调用marqueeEnd函数 <!-- marqueeEnd --> </SCRIPT> </td> </tr> </table> </center> </div> [下载该程序]
源代码网供稿. |