gpt4 book ai didi

支持IE,firefxo,chrome浏览器下鼠标拖动和拖拽的鼠标指针特效

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 25 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章支持IE,firefxo,chrome浏览器下鼠标拖动和拖拽的鼠标指针特效由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

核心代码:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" />
<title>鼠标拖动和拖拽的鼠标指针特效</title>
<style>
#box{width:100px;height:100px;background:#966;position:absolute;left:100px;top:100px;cursor:pointer;}
</style>
</head>
<body>
<div id= "box" ></div>
<script>
var doc=document;
function getViewport(){
   return {width:Math.max(document.documentElement.clientWidth,document.documentElement.scrollWidth),
       height:Math.max(document.documentElement.clientHeight,document.documentElement.scrollHeight)
   };
}
function compareNum(x,minNum,maxNum){
  switch ( true ){
  case x<minNum:x=minNum; break ;
  case x>maxNum:x=maxNum; break ;
  default :x;
  }
  return x;
  }
 
box.style.left= '100px'
box.style.top= '100px'
 
box.onmousedown= function (e){
  var e=e||window.event;
  var maxL=getViewport().width-100,
    maxT=getViewport().height-100;
  this .startL=parseInt( this .style.left);
  this .startT=parseInt( this .style.top);
  //alert(e.clientX)
  this .startX=e.clientX;
  this .startY=e.clientY;
  //alert(maxL+':'+maxT+':'+L+':'+T)
  doc.onmousemove= function (e){
  posXY(e,0,0,maxL,maxT);
  };
  doc.onmouseup= function (){
   doc.onmousemove= null ;
  doc.onmouseup= null ;
  };
  return false ;
}
function posXY(e,minL,minT,maxL,maxT){
   var e=e||window.event;
  var x=box.startL-(box.startX-e.clientX);
  var y=box.startT-(box.startY-e.clientY);
  box.style.left=compareNum(x,minL,maxL)+ 'px'
  box.style.top=compareNum(y,minT,maxT)+ 'px'
}
</script>
</body>
</html>

  。


  。

最后此篇关于支持IE,firefxo,chrome浏览器下鼠标拖动和拖拽的鼠标指针特效的文章就讲到这里了,如果你想了解更多关于支持IE,firefxo,chrome浏览器下鼠标拖动和拖拽的鼠标指针特效的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com