用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - javascript代码库

跟随鼠标的图片

2012-12-03 作者: 程序猿style举报

[javascript]代码库

<html>
<head>
<title>跟随鼠标的图像</title>
</head>
<body>
<script language="JavaScript">
    var newtop=0
    var newleft=0
    layerStyleRef="layer.style.";
    layerRef="document.all";
    styleSwitch=".style";
    function doMouseMove()
    {
        layerName = 'picture'
        eval('var curElement='+layerRef+'["'+layerName+'"]')
        eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"')
        eval('curElement'+styleSwitch+'.visibility="visible"')
        eval('newleft=document.body.clientWidth-curElement'+styleSwitch+'.pixelWidth')
        eval('newtop=document.body.clientHeight-curElement'+styleSwitch+'.pixelHeight')
        eval('height=curElement'+styleSwitch+'.height')
        eval('width=curElement'+styleSwitch+'.width')
        width=parseInt(width)
        height=parseInt(height)
 
        if (event.clientX > (document.body.clientWidth - width))
        {
        newleft=document.body.clientWidth + document.body.scrollLeft- width
        }
        else{newleft=document.body.scrollLeft + event.clientX}
 
        eval('curElement'+styleSwitch+'.pixelLeft=newleft')
 
        if (event.clientY > (document.body.clientHeight - height))
        {
        newtop=document.body.clientHeight + document.body.scrollTop - height
        }
        else
        {
        newtop=document.body.scrollTop + event.clientY
        }
        eval('curElement'+styleSwitch+'.pixelTop=newtop')
    }
    document.onmousemove = doMouseMove;
    document.write("<img ID=picture src='pic01.gif' Style='position:absolute;TOP:0pt;LEFT:0pt;Z-INDEX:2; visibility:hidden;'>");
 
</script>
</body>
</html>


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...