日期:2014-05-17 浏览次数:20795 次
//拖拽对象 function drag(elementToDrag, event) { var startX = event.clientX, startY = event.clientY; var origX = elementToDrag.offsetLeft, origY = elementToDrag.offsetTop; var deltaX = startX - origX, deltaY = startY - origY; if (document.addEventListener) { document.addEventListener("mousemove", moveHandler, true); document.addEventListener("mouseup", upHandler, true); } else if (document.attachEvent) { elementToDrag.setCapture(); elementToDrag.attachEvent("onmousemove", moveHandler); elementToDrag.attachEvent("onmouseup", upHandler); elementToDrag.attachEvent("onlosecapture", upHandler); } else { var oldmovehandler = document.onmousemove; var olduphandler = document.onmouseup; document.onmousemove = moveHandler; document.onmouseup = upHandler; } if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true; if (event.preventDefault) event.preventDefault(); else event.returnValue = false; function moveHandler(e) { if (!e) e = window.event; elementToDrag.style.left = (e.clientX - deltaX) + "px"; elementToDrag.style.top = (e.clientY - deltaY) + "px"; if(e.clientX - deltaX<0)elementToDrag.style.left = "0px";//out of screen if(e.clientY - deltaY<0)elementToDrag.style.top = "0px";//out of screen if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; } function upHandler(e) { if (!e) e = window.event; if (document.removeEventListener) { document.removeEventListener("mouseup", upHandler, true); document.removeEventListener("mousemove", moveHandler, true); } else if (document.detachEvent) { elementToDrag.detachEvent("onlosecapture", upHandler); elementToDrag.detachEvent("onmouseup", upHandler); elementToDrag.detachEvent("onmousemove", moveHandler); elementToDrag.releaseCapture(); } else { document.onmouseup = olduphandler; document.onmousemove = oldmovehandler; } if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; } } //window 弹出层 var win = function() { this.imageURL = "http://www.gpsoo.net/dealer/images/"; this.nullUrl = "http://www.gpsoo.net/images/"; }; win.prototype.openWinLayer = function(title, htmlStr, width, height, contentType, win, callback) { overWindow = win; this.closeWinLayer(); var title = '<div id="tit" onmousedown=\'drag(document.getElementById("openWinLayerDIV"),event)\' style="height:24px;background:#2b98cd;color:#FFF;cursor:move;"><div style="float:left;width:auto;padding-left:10px;height:24px;line-height:24px;font-size:12px;font-weight:bold;">' + title + '</div><div style="float:right;padding-right:4px;padding-top:3px;"><a style="cursor:pointer;" onclick="win.minWinLayer(\'' + title + '\');"><img src="' + this.imageURL + 'iw_min.gif" border="0" /></a><a><img src="' + this.nullUrl + 'null.gif" width="5" height="14" border="0" /></a><a style="cursor:pointer;" onclick="win.closeWinLayer();"><img src="' + this.imageURL + 'iw_close.gif" border="0" /></a></div></div>'; var contentDiv = top.document.createElement("div"); contentDiv.style.width = (width - 2) + "px"; contentDiv.style.height = (height - 28) + "px"; if (contentType == 2) { var temp = "<iframe width='100%' style='height:" + (height - 28) + "px' name='openWinLayerIframe' id='openWinLayerIframe' src='" + htmlStr + "' frameborder='0' scrolling='" + 'auto' + "'></iframe>"; contentDiv.innerHTML = temp; } else { contentDiv.innerHTML = htmlStr; } var container = document.createElement(