![javascript实现可拖动变色并关闭层窗口实例【javascript】](https://1200zi.500zi.com/uploadfile/img/14/552/b70f1b4fb1452505c8292e8f6dd34359.jpg)
web前端|js教程
javascript,拖动,变色,关闭层窗口
web前端-js教程
迅雷的源码,ubuntu16 lxde,启动tomcat报空指针,kegg爬虫程序,saas技术架构php学习,seo笑话lzw
这是一款基于javascript+CSS实现层拖动的代码,不同的是它在拖动的时候窗口会变色,使操作体验更好一些,你可以运行代码查看效果。它还可以显示/隐藏或关闭打开的效果,没事的时候推敲一下
asp小学教务源码,ubuntu 应用软件,中间件tomcat使用方法,爬虫用法电商,php最新系统学习交流,seo职业计划lzw
拖动窗口<!--var x0=0,y0=0,x1=0,y1=0;var offx=6,offy=6;var moveable=false;var hover=orange,normal=#336699;//color;var index=10000;//z-index;//开始拖动;function startDrag(obj){if(event.button==1){//锁定标题栏;obj.setCapture();//定义对象;var win = obj.parentNode;var sha = win.nextSibling;//记录鼠标和层位置;x0 = event.clientX;y0 = event.clientY;x1 = parseInt(win.style.left);y1 = parseInt(win.style.top);//记录颜色;normal = obj.style.backgroundColor;//改变风格;obj.style.backgroundColor = hover;win.style.borderColor = hover;obj.nextSibling.style.color = hover;sha.style.left = x1 + offx;sha.style.top = y1 + offy;moveable = true;}}//拖动;function drag(obj){if(moveable){var win = obj.parentNode;var sha = win.nextSibling;win.style.left = x1 + event.clientX - x0;win.style.top = y1 + event.clientY - y0;sha.style.left = parseInt(win.style.left) + offx;sha.style.top = parseInt(win.style.top) + offy;}}//停止拖动;function stopDrag(obj){if(moveable){var win = obj.parentNode;var sha = win.nextSibling;var msg = obj.nextSibling;win.style.borderColor = normal;obj.style.backgroundColor = normal;msg.style.color = normal;sha.style.left = obj.parentNode.style.left;sha.style.top = obj.parentNode.style.top;obj.releaseCapture();moveable = false;}}//获得焦点;function getFocus(obj){if(obj.style.zIndex!=index){index = index + 2;var idx = index;obj.style.zIndex=idx;obj.nextSibling.style.zIndex=idx-1;}}//最小化;function min(obj){var win = obj.parentNode.parentNode;var sha = win.nextSibling;var tit = obj.parentNode;var msg = tit.nextSibling;var flg = msg.style.display=="none";if(flg){win.style.height = parseInt(msg.style.height) + parseInt(tit.style.height) + 2*2;sha.style.height = win.style.height;msg.style.display = "block";obj.innerHTML = "0";}else{win.style.height = parseInt(tit.style.height) + 2*2;sha.style.height = win.style.height;obj.innerHTML = "2";msg.style.display = "none";}}//创建一个对象;function xWin(id,w,h,l,t,tit,msg){index = index+2;this.id = id;this.width = w;this.height = h;this.left = l;this.top = t;this.zIndex = index;this.title = tit;this.message = msg;this.obj = null;this.bulid = bulid;this.bulid();}//初始化;function bulid(){var str = ""+ "
"+ "
"+ "" + this.title + ""+ "0"+ "r"+ "
"+ "
" + this.message + "
"+ "
"+ "
";document.body.insertAdjacentHTML("beforeEnd",str);}//显示隐藏窗口function ShowHide(id,dis){var bdisplay = (dis==null)?((document.getElementById("xMsg"+id).style.display=="")?"none":""):disdocument.getElementById("xMsg"+id).style.display = bdisplay;document.getElementById("xMsg"+id+"bg").style.display = bdisplay;}//-->Windows 1Windows 2Windows 3
易企秀h5场景源码下载,关闭ubuntu屏幕保护,两台tomcat多少并发,烧水壶爬虫子,php关于修饰符描述,新区网站seolzw