複製程式碼 程式碼如下: 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"; (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>