| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1053 人关注过本帖
标题:求助,asp.net如何实现鼠标跟随啊?
只看楼主 加入收藏
shezhenhui1989
Rank: 1
来 自:安徽
等 级:新手上路
帖 子:287
专家分:0
注 册:2008-2-1
收藏
 问题点数:0 回复次数:4 
求助,asp.net如何实现鼠标跟随啊?
像网页中嵌的广告一样,一个小图片,鼠标移到哪它就跟随?
搜索更多相关主题的帖子: 鼠标 广告 asp 跟随 网页 
2008-02-28 12:54
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
把如下代码加入<body>区域中
<STYLE type=TEXT/CSS>
.tm {
    FILTER: Alpha(Opacity=50)
}
</STYLE>
 <DIV id=Layer1  style="HEIGHT: 31px; LEFT: 409px; POSITION: absolute; TOP: 131px; WIDTH: 14px"><IMG  class=tm src="girl0508.gif"></DIV>
<SCRIPT>
function move_layer()
{
Layer1.style.left=event.clientX+document.body.scrollLeft+10;
Layer1.style.top=event.clientY+document.body.scrollTop+10;
top.status="鼠标X="+event.clientX + " sX=" + document.body.scrollLeft + " 鼠标Y=" + event.clientY+ "  sY=" + document.body.scrollTop;
}
document.onmousemove =move_layer;
</SCRIPT>

飘过~~
2008-02-28 12:58
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
第一步:把如下代码加入<body>区域中
<SCRIPT LANGUAGE="JavaScript">
    var newtop=0
    var newleft=0
    if (navigator.appName == "Netscape") {
        layerStyleRef="layer.";
        layerRef="document.layers";
        styleSwitch="";
        }
        else
        {
        layerStyleRef="layer.style.";
        layerRef="document.all";
        styleSwitch=".style";

        }

    function doMouseMove() {

        layerName = 'iit'

        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 - 5 - width))
        {
        newleft=document.body.clientWidth + document.body.scrollLeft - 5 - width
        }
        else
        {
        newleft=document.body.scrollLeft + event.clientX
        }
        eval('curElement'+styleSwitch+'.pixelLeft=newleft')

        if (event.clientY > (document.body.clientHeight - 5 - height))
        {
        newtop=document.body.clientHeight + document.body.scrollTop - 5 - height
        }
        else
        {
        newtop=document.body.scrollTop + event.clientY
        }
        eval('curElement'+styleSwitch+'.pixelTop=newtop')
}
document.onmousemove = doMouseMove;

</SCRIPT>
第二步:把如下代码加入<body>区域中
<script language="javascript">
    if (navigator.appName == "Netscape") {

    }
    else
    {
        document.write('<div ID=OuterDiv>')
        document.write('<img ID=iit src="image1.gif" STYLE="position:absolute;TOP:0pt;LEFT:0pt;width=103;height=28;Z-INDEX:2;visibility:hidden;">')
        document.write('</div>')
    }
</script>

飘过~~
2008-02-28 13:02
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
把如下代码加入<body>区域中
<SCRIPT language="JavaScript">
<!--
B=document.all;
C=document.layers;
T1=new Array("trail1.gif",38,35,"trail2.gif",30,31,"trail3.gif",28,26,"trail4.gif",22,21,"trail5.gif",16,16)
nos=parseInt(T1.length/3)
rate=50
ie5fix1=0;
ie5fix2=0;
for (i=0;i<nos;i++){
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")}
function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){
with (document){
write((!B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+"; ");
if(St){
if (C)
write(" style='");
write(St+";' ")
}
else write((B)?"'":"");
write((At)? At+">" : ">");
write((HT) ? HT : "");
if (!Op)
closeContainer(N)
}
}
function closeContainer(){
document.write((B)?"</div>":"</layer>")
}
function getXpos(N){
return (B) ? parseInt(B[N].style.left) : C[N].left
}
function getYpos(N){
return (B) ? parseInt(B[N].style.top) : C[N].top
}

function moveContainer(N,DX,DY){
c=(B) ? B[N].style :C[N];c.left=DX;c.top=DY
}
function cycle(){
//if (IE5)
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))
}
}
function newPos(e){
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2
)
}
if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)

//-->


</SCRIPT>

飘过~~
2008-02-28 13:03
shezhenhui1989
Rank: 1
来 自:安徽
等 级:新手上路
帖 子:287
专家分:0
注 册:2008-2-1
收藏
得分:0 
回复 2# 的帖子
谢谢版主啊
2008-02-28 13:40
快速回复:求助,asp.net如何实现鼠标跟随啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015776 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved