按着鼠标右键滑动,会显示其滑动轨迹,也就是会出现相应的线条,这种效果是怎么实现的呢? 问一下大家,有谁了解:在浏览器当前页面,按着鼠标右键滑动,页面上会有鼠标滑动的轨迹(线条)出现,这种效果是怎么实现的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我们有个基于HTML5的类似功能。实现估计类似。js监听鼠标右键摁下,监听鼠标移动,监听鼠标抬起。在移动的方法中做绘制。 就是判断鼠标右键啊设置一个变量保存鼠标状态按下了,记录一下起点坐标,设置变量为true,移动了,记录一下新位置的坐标,把此坐标跟上一个坐标连接(如果没有,连接起点坐标)起来,松开了,记录一下终点坐标,把终点坐标跟上一个坐标连接起来(就是移动的时候不停的记录下的坐标取最后一个),设置状态变量为false。用canvas,svg,vml来做比较简单吧。。不然用纯js+html标签画出来的效果不是很好。 不一定非要html5<script> window.onload = function(){ document.onmousedown=function(e){ e=e||window.event; if(2==e.button){ document.onmousemove = function (e) { var oe = e || window.event; var div = document.createElement("div"); div.className="li"; div.style.left=oe.clientX + "px"; div.style.top=oe.clientY + "px"; document.body.appendChild(div); }; document.onmouseup = function () { document.onmousemove = null; }; } }; }; </script> 补上样式: <style> .li{position: absolute;width: 2px;height:2px;background-color: #000} </style> js 1.1加0.6 等于1.7000000000000001 ??? javascript外部导入的问题 js导出excel合并单元格 一个Jquery读XML的问题,结果搞头大了。。求解 内网用户搭建的网站,怎么才能被外网访问? 日期比较 兄弟们,给一段数据库链接的代码吧,谢谢 求救:表格排序脚本 如何引用ModalDialog中的表单域的值 请教帮主! JS OPEN问题 求这个网站到底隐藏的代码在哪里?
按下了,记录一下起点坐标,设置变量为true,
移动了,记录一下新位置的坐标,把此坐标跟上一个坐标连接(如果没有,连接起点坐标)起来,
松开了,记录一下终点坐标,把终点坐标跟上一个坐标连接起来(就是移动的时候不停的记录下的坐标取最后一个),设置状态变量为false。用canvas,svg,vml来做比较简单吧。。不然用纯js+html标签画出来的效果不是很好。
<script>
window.onload = function(){
document.onmousedown=function(e){
e=e||window.event;
if(2==e.button){
document.onmousemove = function (e) {
var oe = e || window.event;
var div = document.createElement("div");
div.className="li";
div.style.left=oe.clientX + "px";
div.style.top=oe.clientY + "px";
document.body.appendChild(div);
};
document.onmouseup = function () {
document.onmousemove = null;
};
}
};
};
</script>
.li{position: absolute;width: 2px;height:2px;background-color: #000}
</style>