教程集 www.jiaochengji.com
教程集 >  脚本编程  >  vbscript  >  正文 vbscript实例-跟踪鼠标的轨迹

vbscript实例-跟踪鼠标的轨迹

发布时间:2014-08-15   编辑:jiaochengji.com
vbscript实例-跟踪鼠标的轨迹

    此文档含有命名为“Image”的锚,当鼠标指针在其之上移动时,此锚将产生事件。VBScript 事件处理程序跟踪鼠标的移动并改变文本框中的信息。
    单击时,Image 产生 OnClick 事件,使 VBScript 事件处理程序运行。此事件处理程序通过修改 Location 对象的 hRef 属性的值以超链接到适当的页面。
    此“客户端图像映射”方法优于传统的图像映射法。首先,有更高的交互性。此样例中,用户移动鼠标时,描述性文本框立刻作出反应。其次,因为无需使用网络进行击点检测,所以保持了网络带宽。

复制代码 代码如下:

<SCRIPT LANGUAGE="VBScript">
     ' 记下上次单击的位置。
     Dim mX, mY

     Sub Image_MouseMove(s, b, x, y)
      mX = x
      mY = y
     
      If InRect(x, y, 5, 30, 120, 85) Then
       Call DescribeLink("Microsoft 产品目录")

      ElseIf InRect(x, y, 5, 95, 120, 135) then
       Call DescribeLink("Microsoft 产品支持选项")

      ElseIf InRect(x, y, 5, 150, 120, 190) then
       Call DescribeLink("免费下载 Microsoft 软件")

      ElseIf InRect(x, y, 470, 30, 570, 47) then
       Call DescribeLink("Internet 教程")

      ElseIf InRect(x, y, 470, 70, 570, 87) then
       Call DescribeLink("使用搜索服务以查找 Internet 上的任何内容")

      ElseIf InRect(x, y, 470, 105, 570, 122) then
       Call DescribeLink("我们已把有帮助的和便利的 Web 资源放于您的手中")

      ElseIf InRect(x, y, 470, 140, 570, 157) then
       Call DescribeLink("查看本周精选")

      ElseIf InRect(x, y, 470, 175, 570, 192) then
       Call DescribeLink("关于 Microsoft 网络")

      Else
       DescribeLink ""
      End If
     End Sub

     Sub Image_OnClick()
      If InRect(mX, mY, 5, 30, 120, 85) Then
       location.href = "http://www.jiaochengji.com/products/msprod.htm"

      ElseIf InRect(mX, mY, 5, 95, 120, 135) then
       location.href = "http://www.microsoft.com/support/"

      ElseIf InRect(mX, mY, 5, 150, 120, 190) then
       location.href = "http://www.jiaochengji.com/products/intprod.htm"

      ElseIf InRect(mX, mY, 470, 30, 570, 47) then
       location.href = "http://www.jiaochengji.com/tutorial/default.html"

      ElseIf InRect(mX, mY, 470, 70, 570, 87) then
       location.href = "http://www.jiaochengji.com/access/allinone.asp"

      ElseIf InRect(mX, mY, 470, 105, 570, 122) then
       location.href = "http://www.jiaochengji.com/access/ref.asp"

      ElseIf InRect(mX, mY, 470, 140, 570, 157) then
       location.href = "http://www.jiaochengji.com/access/links/other.htm"

      ElseIf InRect(mX, mY, 470, 175, 570, 192) then
       location.href = "http://www.jiaochengji.com/about/jbxue.htm"
      End If
     End Sub

     Function InRect(x, y, Rect_x1, Rect_y1, Rect_x2, Rect_y2)
      InRect =  x > Rect_x1 And x < Rect_x2 And y > Rect_y1 And y < Rect_y2
     End Function

     Sub DescribeLink(Text)
      TxtLinkDescription.Value = Text
     End Sub
    </SCRIPT>

您可能感兴趣的文章:
vbscript实例-跟踪鼠标的轨迹
Python traceback模块:获取异常信息
如何利用canvas实现按住鼠标移动绘制出轨迹
Python3爬虫进阶:识别极验滑动验证码
CSS样式问题集锦
怎么使用ie11 中的“跟踪保护”功能
使用canvas实现迷宫游戏
HTML5的Canvas实现绘制曲线的方法
css3 html5实现太阳系行星公转动画实例
html5中返回AudioTrackList对象的属性audioTracks

[关闭]
~ ~