📄 comm.js
字号:
//制造阴影效果function writeShadow(id, leftoffset, topoffset){ var height = document.getElementById(id).offsetHeight; var width = document.getElementById(id).offsetWidth; var left = leftoffset; var top = topoffset; document.write('<div style=\"position:absolute; left:'+left+'px; top:'+top+'px; width:'+width+'px; height:'+height+'px; '); document.write('z-index:-1; background-color: #000000; layer-background-color: #000000; border: 1px none #000000;'); document.write('filter:'); document.write('Alpha(Opacity=20);\"></div>');}//制造阴影效果function writeShadow2(id1, id2, leftoffset, topoffset){ var height = document.getElementById(id1).offsetHeight; var width = document.getElementById(id1).offsetWidth; var left = leftoffset; var top = topoffset; document.write('<div id=\"'+id2+'\" style=\"position:absolute; left:'+left+'px; top:'+top+'px; width:'+width+'px; height:'+height+'px; '); document.write('z-index:-1; background-color: #000000; layer-background-color: #000000; border: 1px none #000000;'); document.write('filter:'); document.write('Alpha(Opacity=20);\"></div>');}//选择全部多选框function selectAll(cbID,status){ var chbox=document.getElementsByName(cbID); var myL=chbox.length; for(i=0;i<myL;i++){ chbox[i].checked=status; }}//email地址有效性检测function validateEmail(email){ var emailStr = email; //或 var re=/^[\w.-]+@([0-9a-z][\w-]+\.)+[a-z]{2,3}$/i; //\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* //http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)? var re=new RegExp("^[\\w.-]+@([0-9a-z][\\w-]+\\.)+[a-z]{2,3}$","i"); if(re.test(emailStr)){ return true; } else{ return false; }}//去掉左空格function LTrim(str){ var i; for(i=0;i<str.length;i++){ if(str.charAt(i)!=" "&&str.charAt(i)!=" "){ break; } } str=str.substring(i,str.length); return str;}//去掉右空格function RTrim(str){ var i; for(i=str.length-1;i>=0;i--){ if(str.charAt(i)!=" "&&str.charAt(i)!=" "){ break; } } str=str.substring(0,i+1); return str;}//去掉两边空格function Trim(str){ return LTrim(RTrim(str));}//检查密码,只能为字母或数字function CheckPassword(str){ var rc=true; if (str+"" == "undefined" || str == null){ rc=false; } else { for(i=0;i<str.length;i++){ if(str.charAt(i)<'0'||(str.charAt(i)>'9' && str.charAt(i)<'A')||(str.charAt(i)>'Z' && str.charAt(i)<'a')||str.charAt(i)>'z'){ rc= false; break; } } } return rc;}//检查用户名(中文,英文字母或数字)function CheckUsername(str){ var rc=true; if (str+"" == "undefined" || str == null){ rc=false; } else { for(i=0;i<str.length;i++){ if((str.charAt(i)<'0'||(str.charAt(i)>'9' && str.charAt(i)<'A')||(str.charAt(i)>'Z' && str.charAt(i)<'a')||str.charAt(i)>'z')&&!checkChinese(str.charAt(i))){ rc= false; break; } } } return rc;}//检查输入参数是否为整数function CheckInteger(str){ var rc=true; if (str+"" == "undefined" || str == null){ rc=false; } else{ for(i=0;i<str.length;i++){ if(i==0 && str.charAt(i)=='-'){ continue; } if(str.charAt(i)<'0' || str.charAt(i)>'9'){ rc=false; break; } } } return rc;}//检查中文function checkChinese(input){ var re = /[\u4E00-\u9FA0]+/; if (re.test(input)){ return true; } else{ return false; }}function CheckNumber(str){ var rc=true; if (str+"" == "undefined" || str == null){ rc=false; } else if(str.length==0){ rc=false; } else{ for(i=0;i<str.length;i++){ if(str.charAt(i)<'0' || str.charAt(i)>'9'){ rc=false; break; } } } return rc;}//显示或隐藏某一元素,根据id值function showHidden(id,disValue){ document.getElementById(id).style.display=disValue;}//显示或隐藏某一元素,根据id值function showHidden2(id){ if(document.getElementById(id).style.display=='none'){ document.getElementById(id).style.display='block'; } else{ document.getElementById(id).style.display='none'; }}//更改当前窗口hreffunction changeHRef(url){ window.location.href=url;}//选择目前选中的选项function selectOption(id, value){ var select = document.getElementById(id); for(i=0;i<select.options.length;i++){ if(select.options[i].value==value){ select.options[i].selected=true; break; } }}function selectRadio(id, value){ var select = document.getElementById(id); alert(select);// for(i=0;i<select.options.length;i++){// if(select.options[i].value==value){// select.options[i].selected=true;// break;// }// }}function sendRequest(url){ if (window.XMLHttpRequest) { xml = new XMLHttpRequest(); } else if (window.ActiveXObject) { xml = new ActiveXObject("Microsoft.XMLHTTP"); } xml.onreadystatechange = onStatusChange; xml.open("GET", url, true); xml.send(null);}function onStatusChange(){ if (xml.readyState == 4){ if (xml.status==200){ onReadyDo(); } else{ alert( 'HTTP Error ' + xml.status + ': ' + xml.statusText); } }}////////////////第二个JAXA函数//////////////////var gId;function sendRequest2(id, url){ gId = id; if (window.XMLHttpRequest) { xml = new XMLHttpRequest(); } else if (window.ActiveXObject) { xml = new ActiveXObject("Microsoft.XMLHTTP"); } xml.onreadystatechange = onStatusChange2; xml.open("GET", url, true); xml.send(null);}function onStatusChange2(){ if (xml.readyState == 4){ if (xml.status==200){ document.getElementById(gId).innerHTML = xml.responseText; } else{ alert('HTTP Error ' + xml.status + ': ' + xml.statusText); } }}////////////////结束 第二个JAXA函数//////////////////////////////////第三个AJAX函数///////////////////** * XMLHttpRequest Object Pool * * @author legend <legendsky@hotmail.com> * @link http://www.ugia.cn/?p=85 * @Copyright www.ugia.cn */var XMLHttp = { _objPool: [], _getInstance: function () { for (var i = 0; i < this._objPool.length; i ++) { if (this._objPool[i].readyState == 0 || this._objPool[i].readyState == 4) { return this._objPool[i]; } } // IE5中不支持push方法 this._objPool[this._objPool.length] = this._createObj(); return this._objPool[this._objPool.length - 1]; }, _createObj: function () { if (window.XMLHttpRequest) { var objXMLHttp = new XMLHttpRequest(); } else { var MSXML = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP']; for(var n = 0; n < MSXML.length; n ++) { try { var objXMLHttp = new ActiveXObject(MSXML[n]); break; } catch(e) { } } } // mozilla某些版本没有readyState属性 if (objXMLHttp.readyState == null) { objXMLHttp.readyState = 0; objXMLHttp.addEventListener("load", function () { objXMLHttp.readyState = 4; if (typeof objXMLHttp.onreadystatechange == "function") { objXMLHttp.onreadystatechange(); } }, false); } return objXMLHttp; }, // 发送请求(方法[post,get], 地址, 数据, 回调函数) sendReq: function (method, url, data, id, callback, charset) { var objXMLHttp = this._getInstance(); with(objXMLHttp) { try { // 加随机数防止缓存 if (url.indexOf("?") > 0) { url += "&randnum=" + Math.random(); } else { url += "?randnum=" + Math.random(); } open(method, url, true); // 设定请求编码方式 setRequestHeader("Content-Type", "text/xml"); setRequestHeader("charset", charset); //setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset='+charset); send(data); onreadystatechange = function () { if (objXMLHttp.readyState == 4 && (objXMLHttp.status == 200 || objXMLHttp.status == 304)) { callback(objXMLHttp, id); } } } catch(e) { alert(e); } } }};function changeInnerHTMLById(obj, id){ if(document.getElementById(id)!=null){ document.getElementById(id).innerHTML = obj.responseText; } else{ parent.document.getElementById(id).innerHTML = obj.responseText; }}function sendRequest3(id, url){ if(document.getElementById(id)!=null){ document.getElementById(id).innerHTML = "<div align='center'><img src='/images/loading.gif'><br>正在读取……</div>"; } else{ parent.document.getElementById(id).innerHTML = "<div align='center'><img src='/images/loading.gif'><br>正在读取……</div>"; } XMLHttp.sendReq('GET', url, '', id, changeInnerHTMLById, 'GBK');}function sendRequest5(id, url){ if(document.getElementById(id)!=null){ document.getElementById(id).innerHTML = "<div align='center'><img src='/images/loading.gif'><br>正在读取……</div>"; } else{ parent.document.getElementById(id).innerHTML = "<div align='center'><img src='/images/loading.gif'><br>正在读取……</div>"; } XMLHttp.sendReq('GET', url, '', id, changeInnerHTMLById, 'GBK');}function sendRequest4(id, url, fun){ if(document.getElementById(id)!=null){ document.getElementById(id).innerHTML = "<div align='center'><img src='/images/loading.gif'><br>正在读取……</div>"; } else{ parent.document.getElementById(id).innerHTML = "<div align='center'><img src='/images/loading.gif'><br>正在读取……</div>"; } XMLHttp.sendReq('POST', url, '', id, fun, 'GBK');}////////////////结束 第三个JAXA函数//////////////////String.prototype.replaceAll = stringReplaceAll;function stringReplaceAll(AFindText,ARepText){ raRegExp = new RegExp(AFindText,"g") return this.replace(raRegExp,ARepText)}function preLoadImage(imgUrl){ var heavyImage = new Image(); heavyImage.src = imgUrl;}function showWindow(title, url){ document.getElementById("windowTitle").innerHTML=title; document.getElementById("windowDiv").style.top=150; document.getElementById("windowDiv").style.left=document.body.clientWidth/2-200+document.body.scrollLeft; document.getElementById("windowDiv").style.display="block"; sendRequest4("windowContent", url, changeShadowAndInnerHTML);}function closeWindow(){ document.getElementById("windowDiv").style.display="none"; hiddenDisableDiv();}function showDisableDiv(){ //得到浏览器窗口的大小 if(document.body.scrollHeight>document.body.clientHeight){ document.getElementById("disDiv").style.height=document.body.scrollHeight; } else{ document.getElementById("disDiv").style.height=document.body.clientHeight; } if(document.body.scrollWidth>document.body.clientWidth){ document.getElementById("disDiv").style.width=document.body.scrollWidth; } else{ document.getElementById("disDiv").style.width=document.body.clientWidth; } document.getElementById("disDiv").style.display="block";}function hiddenDisableDiv(){ document.getElementById("disDiv").style.display="none";}function reshowShadow(id1, id2){ document.getElementById(id2).style.width=document.getElementById(id1).offsetWidth; document.getElementById(id2).style.height=document.getElementById(id1).offsetHeight;}function changeShadowAndInnerHTML(obj, id){ if(document.getElementById(id)!=null){ document.getElementById(id).innerHTML = obj.responseText; } else{ parent.document.getElementById(id).innerHTML = obj.responseText; } reshowShadow('windowDiv', 'windowShadow');}function resizeimg(ImgD,iwidth,iheight) { var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ if(image.width/image.height>= iwidth/iheight){ if(image.width>iwidth){ ImgD.width=iwidth; ImgD.height=(image.height*iwidth)/image.width; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"×"+image.height; } else{ if(image.height>iheight){ ImgD.height=iheight; ImgD.width=(image.width*iheight)/image.height; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"×"+image.height; } ImgD.style.cursor= "pointer"; //改变鼠标指针 ImgD.onclick = function() { window.open(this.src);} //点击打开大图片 if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器,如果是IE ImgD.title = "请使用鼠标滚轮缩放图片,点击图片可在新窗口打开"; ImgD.onmousewheel = function img_zoom() //滚轮缩放 { var zoom = parseInt(this.style.zoom, 10) || 100; zoom += event.wheelDelta / 12; if (zoom> 0) this.style.zoom = zoom + "%"; return false; } } else { //如果不是IE ImgD.title = "点击图片可在新窗口打开"; } }}function resizeimg2(ImgD,iwidth,iheight) { var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ if(image.width/image.height>= iwidth/iheight){ if(image.width>iwidth){ ImgD.width=iwidth; ImgD.height=(image.height*iwidth)/image.width; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"×"+image.height; } else{ if(image.height>iheight){ ImgD.height=iheight; ImgD.width=(image.width*iheight)/image.height; }else{ ImgD.width=image.width; ImgD.height=image.height; } ImgD.alt=image.width+"×"+image.height; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -