复制代码 代码如下: JAVASCRIPT弹出层 <BR>#popDiv { <BR>position: absolute; <BR>visibility: hidden; <BR>overflow: hidden; <BR>border: 2px solid #AEBBCA; <BR>background-color: #EEF1F8; <BR>cursor: move; <BR>padding: 1px; <BR>} <br><br>#popTitle { <BR>background: #9DACBF; <BR>height: 20px; <BR>line-height: 20px; <BR>padding: 1px; <BR>} <br><br>#popForm { <BR>padding: 2px; <BR>} <br><br>.title_left { <BR>font-weight: bold; <BR>padding-left: 5px; <BR>float: left; <BR>} <br><br>.title_right { <BR>float: right; <BR>} <br><br>#popTitle .title_right a { <BR>color: #000; <BR>text-decoration: none; <BR>} <br><br>#popTitle .title_right a:hover { <BR>text-decoration: underline; <BR>color: #FF0000; <BR>} <BR> <BR>function showPopup() {//弹出层 <BR>var objDiv = document.getElementById("popDiv"); <BR>objDiv.style.top = "50px";//设置弹出层距离上边界的距离 <BR>objDiv.style.left = "200px";//设置弹出层距离左边界的距离 <BR>objDiv.style.width = "300px";//设置弹出层的宽度 <BR>objDiv.style.height = "200px";//设置弹出层的高度 <BR>//objDiv.style.display = "block"; <BR>objDiv.style.visibility = "visible"; <BR>} <BR>function hidePopup() {//关闭层 <BR>var objDiv = document.getElementById("popDiv"); <BR>objDiv.style.visibility = "hidden"; <BR>} <BR> 修改操作 href="#" onclick="hidePopup();">关闭 ID : 名 称 : 电压等级 : 经 度 : 纬 度 : <BR>/*-------------------------鼠标左键拖动---------------------*/ <BR>/*--------当不需要实现此功能时,可以将这一部分代码删除------------*/ <BR>var objDiv = document.getElementById("popDiv"); <BR>var isIE = document.all ? true : false;//判断浏览器类型 <BR>document.onmousedown = function(evnt) {//当鼠标左键按下后执行此函数 <BR>var evnt = evnt ? evnt : event; <BR>if (evnt.button == (document.all ? 1 : 0)) { <BR>mouseD = true;//mouseD为鼠标左键状态标志,为true时表示左键被按下 <BR>} <BR>} <br><br>objDiv.onmousedown = function(evnt) { <BR>objDrag = this;//objDrag为拖动的对象 <BR>var evnt = evnt ? evnt : event; <BR>if (evnt.button == (document.all ? 1 : 0)) { <BR>mx = evnt.clientX; <BR>my = evnt.clientY; <BR>objDiv.style.left = objDiv.offsetLeft + "px"; <BR>objDiv.style.top = objDiv.offsetTop + "px"; <BR>if (isIE) { <BR>objDiv.setCapture(); <BR>//objDiv.filters.alpha.opacity = 50;//当鼠标按下后透明度改变 <BR>} else { <BR>window.captureEvents(Event.MOUSEMOVE);//捕获鼠标拖动事件 <BR>//objDiv.style.opacity = 0.5;//当鼠标按下后透明度改变 <BR>} <BR>} <BR>} <BR>document.onmouseup = function() { <BR>mouseD = false;//左键松开 <BR>objDrag = ""; <BR>if (isIE) { <BR>objDiv.releaseCapture(); <BR>//objDiv.filters.alpha.opacity = 100;//当鼠标左键松开后透明度改变 <BR>} else { <BR>window.releaseEvents(objDiv.MOUSEMOVE);//释放鼠标拖动事件 <BR>//objDiv.style.opacity = 1;//当鼠标左键松开后透明度改变 <BR>} <BR>} <br><br>document.onmousemove = function(evnt) { <BR>var evnt = evnt ? evnt : event; <BR>if (mouseD == true && objDrag) { <BR>var mrx = evnt.clientX - mx; <BR>var mry = evnt.clientY - my; <BR>objDiv.style.left = parseInt(objDiv.style.left) + mrx + "px"; <BR>objDiv.style.top = parseInt(objDiv.style.top) + mry + "px"; <BR>mx = evnt.clientX; <BR>my = evnt.clientY; <BR>} <BR>} <BR> 效果如下图: