//构造函数 function Common() { var newid; } //全选功能 Common.prototype.checkAll = function (tableName, itemName) { var i = 0; while (true) { var e = document.getElementById(tableName + ":" + i + ":" + itemName); if (e == null) { break; } if (e.disabled != true) { e.checked = document.getElementById("chkall").checked; } i += 1; } }; //检测是否选择要处理的数据 Common.prototype.checkSelect = function (checkName) { var checkboxes=document.getElementsByName(checkName); var common_selfjs_tip1 = document.getElementById("common_selfjs_tip1").value; var result=0; if(checkboxes.length){ for(i = 0; i 0){ for(var i=0;i 0) { for (var i = 0; i < allNodes.length; i++) { var node = allNodes[i]; if ((node.type == 'text' || node.type == 'password' || node.type == 'textarea') && node.readOnly != true && node.disabled != true) { node.focus(); return; } } } } }; //页面onload需要执行的动作 Common.prototype.checkEnter= function (form) { //执行focus的动作 if(event.keyCode==13){ if(event.srcElement.type=='textarea') return; var obj; try{ obj=form.document.all.tags("input"); }catch(ex){} if(!obj) return; var objs = []; if(!obj.length) objs[0] = obj; else objs = obj; for(var i=0; i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&imax){ return false; } return true; } /************************************************************************************************************ * DHTML modal dialog box * * Created: August, 26th, 2006 * @class Purpose of class: Display a modal dialog box on the screen. * * Css files used by this script: modal-message.css * * Demos of this class: demo-modal-message-1.html * * Update log: * ************************************************************************************************************/ /** * @constructor */ DHTML_modalMessage = function() { var url; // url of modal message var htmlOfModalMessage; // html of modal message var divs_transparentDiv; // Transparent div covering page content var divs_content; // Modal message div. var layoutCss; // Name of css file; var width; // Width of message box var height; // Height of message box var existingBodyOverFlowStyle; // Existing body overflow css var dynContentObj; // Reference to dynamic content object var cssClassOfMessageBox; // Alternative css class of message box - in case you want a different appearance on one of them var shadowDivVisible; // Shadow div visible ? var shadowOffset; // X and Y offset of shadow(pixels from content box) this.url = ''; // Default url is blank this.htmlOfModalMessage = ''; // Default message is blank this.layoutCss = 'modal-message.css'; // Default CSS file this.height = 200; // Default height of modal message this.width = 400; // Default width of modal message this.cssClassOfMessageBox = false; // Default alternative css class for the message box this.shadowDivVisible = true; // Shadow div is visible by default this.shadowOffset = 5; // Default shadow offset. } DHTML_modalMessage.prototype = { // {{{ setSource(urlOfSource) /** * Set source of the modal dialog box * * * @public */ setSource : function(urlOfSource) { this.url = urlOfSource; } // }}} , // {{{ setHtmlContent(newHtmlContent) /** * Setting static HTML content for the modal dialog box. * * @param String newHtmlContent = Static HTML content of box * * @public */ setHtmlContent : function(newHtmlContent) { this.htmlOfModalMessage = newHtmlContent; } // }}} , // {{{ setSize(width,height) /** * Set the size of the modal dialog box * * @param int width = width of box * @param int height = height of box * * @public */ setSize : function(width,height) { if(width)this.width = width; if(height)this.height = height; } // }}} , // {{{ setCssClassMessageBox(newCssClass) /** * Assign the message box to a new css class.(in case you wants a different appearance on one of them) * * @param String newCssClass = Name of new css class (Pass false if you want to change back to default) * * @public */ setCssClassMessageBox : function(newCssClass) { this.cssClassOfMessageBox = newCssClass; if(this.divs_content){ if(this.cssClassOfMessageBox) this.divs_content.className=this.cssClassOfMessageBox; else this.divs_content.className='modalDialog_contentDiv'; } } // }}} , // {{{ setShadowOffset(newShadowOffset) /** * Specify the size of shadow * * @param Int newShadowOffset = Offset of shadow div(in pixels from message box - x and y) * * @public */ setShadowOffset : function(newShadowOffset) { this.shadowOffset = newShadowOffset } // }}} , // {{{ display() /** * Display the modal dialog box * * * @public */ display : function() { // ================ hide all select, Hubing added, begin =============== //var selects = document.getElementsByTagName("select"); //if(selects) { // for(var i=0; i tag back to default. /* Hiding divs */ this.divs_transparentDiv.style.display='none'; this.divs_content.style.display='none'; this.divs_shadow.style.display='none'; } // }}} , // {{{ __createDivs() /** * Create the divs for the modal dialog box * * * @private */ __createDivs : function() { // Creating transparent div this.divs_transparentDiv = document.createElement('DIV'); this.divs_transparentDiv.className='modalDialog_transparentDivs'; this.divs_transparentDiv.style.left = '0px'; this.divs_transparentDiv.style.top = '0px'; document.body.appendChild(this.divs_transparentDiv); // Creating content div this.divs_content = document.createElement('DIV'); this.divs_content.className = 'modalDialog_contentDiv'; this.divs_content.id = 'DHTMLSuite_modalBox_contentDiv'; document.body.appendChild(this.divs_content); // Creating shadow div this.divs_shadow = document.createElement('DIV'); this.divs_shadow.className = 'modalDialog_contentDiv_shadow'; document.body.appendChild(this.divs_shadow); } // }}} , // {{{ __resizeDivs() /** * Resize the message divs * * * @private */ __resizeDivs : function() { var topOffset = Math.max(document.body.scrollTop,document.documentElement.scrollTop); var leftOffset = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft); if(this.cssClassOfMessageBox) this.divs_content.className=this.cssClassOfMessageBox; else this.divs_content.className='modalDialog_contentDiv'; if(!this.divs_transparentDiv)return; document.documentElement.style.overflow = 'hidden'; var bodyWidth = document.documentElement.clientWidth; var bodyHeight = document.documentElement.clientHeight; var bodyWidth, bodyHeight; if (self.innerHeight){ // all except Explorer bodyWidth = self.innerWidth; bodyHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode bodyWidth = document.documentElement.clientWidth; bodyHeight = document.documentElement.clientHeight; } else if (document.body) {// other Explorers bodyWidth = document.body.clientWidth; bodyHeight = document.body.clientHeight; } // Setting width and height of content div this.divs_content.style.width = this.width + 'px'; this.divs_content.style.height= this.height + 'px'; // Creating temporary width variables since the actual width of the content div could be larger than this.width and this.height(i.e. padding and border) var tmpWidth = this.divs_content.offsetWidth; var tmpHeight = this.divs_content.offsetHeight; // Setting width and height of left transparent div //this.divs_transparentDiv.style.width = Math.ceil((bodyWidth - tmpWidth) / 2) + 'px'; //this.divs_transparentDiv.style.height = bodyHeight + 'px'; // Setting size extremely large for bottom, left and right side transparent divs. this.divs_transparentDiv.style.top = topOffset; this.divs_transparentDiv.style.left = leftOffset; this.divs_transparentDiv.style.height = '100%'; this.divs_transparentDiv.style.width = '100%'; document.body.scroll='no'; this.divs_content.style.left = (Math.ceil((bodyWidth - tmpWidth) / 2) + leftOffset) + 'px'; this.divs_content.style.top = (Math.ceil((bodyHeight - tmpHeight) / 2) + topOffset) + 'px'; this.divs_shadow.style.left = (this.divs_content.style.left.replace('px','')/1 + this.shadowOffset) + 'px'; this.divs_shadow.style.top = (this.divs_content.style.top.replace('px','')/1 + this.shadowOffset) + 'px'; this.divs_shadow.style.height = tmpHeight + 'px'; this.divs_shadow.style.width = tmpWidth + 'px'; if(!this.shadowDivVisible)this.divs_shadow.style.display='none'; // Hiding shadow if it has been disabled } // }}} , // {{{ __insertContent() /** * Insert content into the content div * * * @private */ __insertContent : function() { if(this.url){ // url specified - load content dynamically ajax_loadContent('DHTMLSuite_modalBox_contentDiv',this.url); }else{ // no url set, put static content inside the message box this.divs_content.innerHTML = this.htmlOfModalMessage; } } } function modelDialog_displayStaticMessage(messageContent,cssClass) { var messageObj = new DHTML_modalMessage(); // We only create one object of this class messageObj.setShadowOffset(5); // Large shadow messageObj.setHtmlContent(messageContent); messageObj.setSize(300,50); messageObj.setCssClassMessageBox(cssClass); messageObj.setSource(false); // no html source since we want to use a static message here. messageObj.setShadowDivVisible(false); // Disable shadow for these boxes messageObj.display(); } /* * Display waiting Info */ function waitForSubmit() { waitFlag = true; var messageObj = new DHTML_modalMessage(); var waitInfo = "" + "" + "
"; var common_managerjs_tip2 = document.getElementById("common_managerjs_tip2").value; waitInfo += "
"+common_managerjs_tip2+"
"; messageObj.setShadowOffset(0); // Large shadow messageObj.setHtmlContent(waitInfo); messageObj.setSize(300, 40); messageObj.setSource(false); // no html source since we want to use a static message here. messageObj.setShadowDivVisible(false); // Disable shadow for these boxes messageObj.display(false); } var waitFlag = false; //操作正在进行中为true function keyDownDeal() { if((window.event.keyCode==13 || window.event.keyCode==32)&& waitFlag) // 操作进行中,屏蔽回车键,解决BUG 33033 { window.event.keyCode = 0; window.event.returnValue = false; } } document.body.onkeydown = keyDownDeal; function modelDialog_closeMessage() { messageObj.close(); } /*去掉textStr两头的空格*/ function trim(str) { var ret = str; ret = ret.replace(/^\s+/, ""); ret = ret.replace(/\s+$/, ""); return ret; } function isChinese(str) { var lst = /[u00-uFF]/; return !lst.test(str); } function strlen(str) { var strlength=0; for (i=0;ilength && length > 3){ return this.substring(0,length-2)+"..."; }else{ return this; } } String.prototype.checkIpIsOk = function(){ MaskStr = this; /* 有效性校验 */ var IPPattern = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; if(!IPPattern.test(MaskStr)){ return false; } /* 检查域值 */ var IPArray = MaskStr.split("."); var ip1 = parseInt(IPArray[0]); var ip2 = parseInt(IPArray[1]); var ip3 = parseInt(IPArray[2]); var ip4 = parseInt(IPArray[3]); if ( ip1<0 || ip1>255 /* 每个域值范围0-255 */ || ip2<0 || ip2>255 || ip3<0 || ip3>255 || ip4<0 || ip4>255 ){ return false; } return true; } //Array的删除方法--真正的删除 !!使用方法 array = array.del(n); Array.prototype.del=function(n) { //n表示第几项,从0开始算起。 //prototype为对象原型,注意这里为对象增加自定义方法的方法。 if(n<0){ //如果n<0,则不进行任何操作。 return this; } else{ this[n] = null; return this.slice(0,n).concat(this.slice(n+1,this.length)); } /* concat方法:返回一个新数组,这个新数组是由两个或更多数组组合而成的。       这里就是返回this.slice(0,n)/this.slice(n+1,this.length)       组成的新数组,这中间,刚好少了第n项。 slice方法: 返回一个数组的一段,两个参数,分别指定开始和结束的位置。 */ } Array.prototype.add = function(obj){ this[this.length] = obj; } Array.prototype.contains = function(str){ if(this.length == 0){return false} for(var i=0;i-1){ px = px.replace("px",""); px *= 1; } return px; }; //js检索浏览器 function getExplorer() { var explorer = window.navigator.userAgent ; var getexplorer; //ie if (explorer.indexOf("MSIE") >= 0) { getexplorer="ie"; } //firefox else if (explorer.indexOf("Firefox") >= 0) { getexplorer="Firefox"; } //Chrome else if(explorer.indexOf("Chrome") >= 0){ getexplorer="Chrome"; } //Opera else if(explorer.indexOf("Opera") >= 0){ getexplorer="Opera"; } //Safari else if(explorer.indexOf("Safari") >= 0){ getexplorer="Safari"; } return getexplorer; }