baidu博客的编辑友情链接的新的层窗口!经典~支持【FF】
baidu博客的编辑友情链接的新的层窗口!经典~支持【FF】
发布时间:2016-12-30 来源:查字典编辑
摘要:varIsDraging=false;varoEdit=null;vardragData=null;varbackData=null;var...

var IsDraging = false; var oEdit=null; var dragData=null ; var backData=null ; var oObj=null; var dragiframe=1; var bNotReloadOnClose = false; var is_opera_d = (navigator.userAgent.toLowerCase().indexOf('opera') != -1); String.prototype.trim = function() { return this.replace(/(^[ |]*)|([ |]*$)/g, ""); } function $(s) { if(document.getElementById) { return eval('document.getElementById("' + s + '")'); } else { return eval('document.all.' + s); } } function $$(s) { return document.frames?document.frames[s]:$(s).contentWindow; } function $c(s) { return document.createElement(s); } function swap(s,a,b,c) { $(s)[a]=$(s)[a]==b?c:b; } function exist(s) { return $(s)!=null; } function dw(s) { document.write(s); } function hide(s) { $(s).style.display=$(s).style.display=="none"?"":"none"; } function isNull(_sVal) { return (_sVal == "" || _sVal == null || _sVal == "undefined"); } function removeNode(s) { if(exist(s)) { $(s).innerHTML = ''; $(s).removeNode?$(s).removeNode():$(s).parentNode.removeChild($(s)); } } function dialog() { var titile = ''; var auto = 'y'; var width = 240; var height = 120; var src = ""; var path = "./";//此处是图片的路径,不包括图片名称 var sFunc = ' '; var sClose = ''; var sBody = '

' + sFunc + '
'; var sIfram = ' '; var sBox = ' 100) { $("dialogBody").innerHTML = _sUrl; } else { var openIframe = ""; $("dialogBody").innerHTML = openIframe; } } } this.showWindow = function(_sUrl, _iWidth, _iHeight, _sMode) { var oWindow; var sLeft = (screen.width) ? (screen.width - _iWidth)/2 : 0; var iTop = -80 + (screen.height - _iHeight)/2; iTop = iTop > 0 ? iTop : (screen.height - _iHeight)/2; var sTop = (screen.height) ? iTop : 0; if(window.showModalDialog && _sMode == "m"){ oWindow = window.showModalDialog(_sUrl,"","dialogWidth:" + _iWidth + "px;dialogheight:" + _iHeight + "px"); } else { oWindow = window.open(_sUrl, '', 'height=' + _iHeight + ', width=' + _iWidth + ', top=' + sTop + ', left=' + sLeft + ', toolbar=no, menubar=no, scrollbars=' + _sMode + ', resizable=no,location=no, status=no'); this.reset(); } } this.event = function(_sMsg, _sOk, _sCancel, _sClose) { $('dialogFunc').innerHTML = sFunc; $('dialogClose').innerHTML = sClose; $('dialogBodyBox') == null ? $('dialogBody').innerHTML = sBody : function(){}; if (width > 400 && height > 300) { $('dialogMsg') ? $('dialogMsg').innerHTML = _sMsg : function(){}; $('dialogMsg') ? $('dialogMsg')['style']['fontWeight'] = "bold" : function(){}; $('dialogMsg') ? $('dialogMsg')['style']['fontSize'] = "15px" : function(){}; $('dialogMsg') ? $('dialogMsg')['style']['color'] = "#ff9900" : function(){}; $('dialogMsg') ? $('dialogMsg')['style']['height'] = "150px" : function(){}; } else { $('dialogMsg') ? $('dialogMsg').innerHTML = _sMsg : function(){}; } _sOk && _sOk != "" ? this.button('dialogOk', _sOk) : $('dialogOk').style.display = 'none'; _sCancel && _sCancel != "" ? this.button('dialogCancel', _sCancel) : $('dialogCancel').style.display = 'none'; //_sOk ? this.button('dialogOk', _sOk) : _sOk == "" ? function(){} : $('dialogCancel').style.display = 'none'; //_sCancel ? this.button('dialogCancel', _sCancel) : _sCancel == "" ? function(){} : $('dialogCancel').style.display = 'none'; _sClose ? this.button('dialogBoxClose', _sClose) : function(){}; this.show(); } this.set = function(_oAttr, _sVal) { var oShadow = $('dialogBoxShadow'); var oDialog = $('dialogBox'); var oHeight = $('dialogHeight'); if(_sVal != '') { switch(_oAttr) { case 'title': $('dialogBoxTitle').innerHTML = _sVal; title = _sVal; break; case 'width': oDialog['style']['width'] = _sVal; width = _sVal; break; case 'height': oHeight['style']['height'] = _sVal; height = _sVal; break; case 'src': $('dialogMsgDiv').innerHTML = '
' + sClose + '

'; $('dialogBoxFace') ? $('dialogBoxFace').src = path + _sVal + '.gif' : function(){}; src = _sVal; break; case 'auto': auto = _sVal; } } this.middle('dialogBox'); oShadow['style']['top'] = oDialog.offsetTop + 6; oShadow['style']['left'] = oDialog.offsetLeft + 6; oShadow['style']['width'] = oDialog.offsetWidth; oShadow['style']['height'] = oDialog.offsetHeight; } this.moveStart = function (event, _sId) { IsDraging = true; oObj = $(_sId); document.onmousemove = mousemove; document.onmouseup = mouseup; document.setCapture ? oObj.setCapture() : function(){}; oEvent = window.event ? window.event : event; dragData = {x : oEvent.clientX, y : oEvent.clientY}; backData = {x : parseInt(oObj.style.top), y : parseInt(oObj.style.left)}; function mousemove() { if(!IsDraging) return ; var oEvent = window.event ? window.event : event; var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left); var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top); oObj.style.left = iLeft; oObj.style.top = iTop; $('dialogBoxShadow').style.left = iLeft + 6; $('dialogBoxShadow').style.top = iTop + 6; if ($('dialogIframBG')) { $('dialogIframBG').style.left = iLeft; $('dialogIframBG').style.top = iTop; } dragData = {x: oEvent.clientX, y: oEvent.clientY}; } function mouseup() { if(!IsDraging) return ; var oEvent = window.event ? window.event : event; document.onmousemove = null; document.onmouseup = null; if(oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > document.body.clientWidth || oEvent.clientY > document.body.clientHeight){ oObj.style.left = backData.y; oObj.style.top = backData.x; $('dialogBoxShadow').style.left = backData.y + 6; $('dialogBoxShadow').style.top = backData.x + 6; if ($('dialogIframBG')) { $('dialogIframBG').style.left = backData.y; $('dialogIframBG').style.top = backData.x; } } IsDraging = false; oObj.releaseCapture ? oObj.releaseCapture() : function(){}; } } this.hideModule = function(_sType, _sDisplay) { var aIframe = parent.document.getElementsByTagName("iframe"); var aType = document.getElementsByTagName(_sType); var iChildObj, iChildLen; for (var i = 0; i < aType.length; i++) { aType.style.display = _sDisplay; } for (var j = 0; j < aIframe.length; j++) { iChildObj = document.frames ? document.frames[j] : aIframe[j].contentWindow; try { iChildLen = iChildObj.document.body.getElementsByTagName(_sType).length; for (var k = 0; k < iChildLen; k++) { iChildObj.document.body.getElementsByTagName(_sType)[k].style.display = _sDisplay; } } catch (e){} } } this.middle = function(_sId) { try { var aIframe = parent.document.getElementById("iframe_parent"); } catch (e){} if (aIframe) { var sClientWidth = aIframe.offsetWidth; var sClientHeight = aIframe.offsetHeight; var sScrollTop = 0; } else { var sClientWidth = parent ? parent.document.body.clientWidth : document.body.clientWidth; var sClientHeight = parent ? parent.document.body.clientHeight : document.body.clientHeight; var sScrollTop = parent ? parent.document.body.scrollTop : document.body.scrollTop; } var sleft = (document.body.clientWidth / 2) - ($(_sId).offsetWidth / 2); var iTop = -80 + (sClientHeight / 2 + sScrollTop) - ($(_sId).offsetHeight / 2); var sTop = iTop > 0 ? iTop : (sClientHeight / 2 + sScrollTop) - ($(_sId).offsetHeight / 2); if(sTop < 1) sTop="20"; if(sleft < 1) sleft="20"; $(_sId)['style']['display'] = ''; $(_sId)['style']['position'] = "absolute"; $(_sId)['style']['left'] = sleft; $(_sId)['style']['top'] = sTop; } } function _error_msg_show(msg, click, icon, title) { click = click ? click : ' '; icon = icon ? icon : ''; title = title ? title : ''; dg=new dialog(); dg.init(); dg.set('src', get_icon(icon)); dg.set('title', title); dg.event(msg, click, '', click); } function get_icon(icons) { var icon = 'login_wrong'; return icon; } function openWindow(_sUrl, _sWidth, _sHeight, _sTitle, _sScroll, _bReload) { bNotReloadOnClose = _bReload || false; if(top.document.embeds){ for(i=0;i maxl) { ta.value = ta.value.substring(0,maxl); } else { zs.value = maxl - ta.value.length; } } 编辑

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类