zoukankan      html  css  js  c++  java
  • 常用JAVASCRIPT集合

    防止右键

    <script language="JavaScript">
    function helpor()
    {
     if (event.button==2)alert(' 仅供浏览!谢谢!\n\n若有问题请与我联系! ')
    }
    </script>
       
    然后把<body> 改为
    <body onmousedown="helpor_net()">


    function AddRefresh(url)
    {
     document.location.href = url;
    }
    //800*600支持
    function InitScroll()
    {
     try
     {
      if(screen.width<'1024')
      {
       document.body.scroll="yes";
      }
     }catch(e) { alert(e.description); }

    }    
    function CheckEnter()
    {
     try{
     }catch(e) { alert(e.description); }
    }
    //防止非法SQL注入
    function CheckErrorText()
    {
     try{
       if ((event.srcElement.type=="text")||(event.srcElement.type=="password")||event.srcElement.tagName=="TEXTAREA")
       {
        //防止非法SQL注入
        var objRe = new RegExp(".*;*(use|exec|insert|select|delete|update|master|declare).*","i");
        if (objRe.test(event.srcElement.value))
        {
         event.srcElement.value="";
         alert("有非法标识请重新输入!");
        }
       
        //判断并避免单引号
        if (event.srcElement.value.indexOf("'")>-1)
        {
         objRe = /'/g;
         event.srcElement.value = event.srcElement.value.replace(objRe,"")
        }
       
        //判断并避免单>
        if (event.srcElement.value.indexOf(">")>-1)
        {
         objRe = />/g;
         event.srcElement.value = event.srcElement.value.replace(objRe,"")
        }
       
        //判断并避免单<
        if (event.srcElement.value.indexOf("<")>-1)
        {
         objRe = /</g;
         event.srcElement.value = event.srcElement.value.replace(objRe,"")
        }
       }
      }catch(e) { alert(e.description); }
    }
    //防止非法SQL注入
    function InitCheckErrorText()
    {
     try{
       var objTags=document.body.getElementsByTagName("INPUT");
      
       for (var intNum=0;intNum<objTags.length;intNum++)
       {
        if (objTags[intNum].type=="text")
        {
         objTags[intNum].attachEvent("onblur", "CheckTagText");
        }
       }
             objTags=document.body.getElementsByTagName("TEXTAREA");
       for (intNum=0;intNum<objTags.length;intNum++)
       {
        objTags[intNum].onblur="CheckErrorText(this)";
       }
      }catch(e) { alert(e.description); }
    }
    //限制输入长度(参数输入this和最大长度如100)
    function textCounter(field, maxlimit) {
        if (field.value.length > maxlimit)
         field.value = field.value.substring(0, maxlimit);
       }
    //防止Text输入非法字符
    function keyInputCheck()
    {
     try{
         if (event.keyCode==124 || event.keyCode==37 || event.keyCode==34 || event.keyCode==39 || event.keyCode==60 ||event.keyCode==62)
            {
             event.keyCode = 0;
             return false;
            }
        }catch(e) { alert(e.description); }
    }
    //防止Text输入非数字字符(float)
    function keyInputNumCheck()
    {
     try{
         if (window.event.keyCode<48 || window.event.keyCode>57)
            {
       if(window.event.keyCode!=46 && window.event.keyCode!=45)
       {
        window.event.keyCode=0;
        return false;
       }
       /*else if(window.event.keyCode == 45)
       {
        var srcObj = window.event.srcElement;
        if((srcObj.tagName == "INPUT")&&(srcObj.type=="text"))
        {
         if(trim(srcObj.value)!="")
         {
          window.event.keyCode=0;
          return false;
         }
        }
       } */       
            }
        }catch(e) { alert(e.description); }
    }

    //防止Text输入非正数字字符(float)
    function keyInputCorrecNumCheck()
    {
     try{
         if (window.event.keyCode<48 || window.event.keyCode>57)
            {
       if(window.event.keyCode!=46)
       {
        window.event.keyCode=0;
        return false;
       }
       /*else if(window.event.keyCode == 45)
       {
        var srcObj = window.event.srcElement;
        if((srcObj.tagName == "INPUT")&&(srcObj.type=="text"))
        {
         if(trim(srcObj.value)!="")
         {
          window.event.keyCode=0;
          return false;
         }
        }
       } */       
            }
        }catch(e) { alert(e.description); }
    }
    //防止输入空格
    function keySpaceCheck()
    {
     try{
       if(window.event.keyCode == 32)
       {
        window.event.keyCode = 0;
        return false;
        }
      }
     catch(e){alert(e.description);}
    }


    //清空控件的数据
    function ClearObjectData(objTag)
    {
     try{
      //Input控件
      var objTags=objTag.getElementsByTagName("INPUT");
      for (var intNum=0;intNum<objTags.length;intNum++)
            {
       if (objTags[intNum].type=="text" || objTags[intNum].type=="hidden")
       {
        objTags[intNum].value="";
       }
            }
           
            //TEXTAREA控件
            var objTags=objTag.getElementsByTagName("TEXTAREA");
      for (var intNum=0;intNum<objTags.length;intNum++)
            {
       objTags[intNum].value="";  
            }
     
        }catch(e) { alert(e.description); }
    }
    //若控件为Text则设为ReadOnly,若为Button则设为Disabled
    function DisableObjectData(objTag)
    {
     try{
      //Input控件
      var objTags=objTag.getElementsByTagName("INPUT");
      for (var intNum=0;intNum<objTags.length;intNum++)
            {
       var typ = objTags[intNum].type;
       if(typ == "text")
        objTags[intNum].readOnly = true;
       else if(typ == "button")
        objTags[intNum].disabled = true;
            }
           
            //TEXTAREA控件
            /*
            var objTags=objTag.getElementsByTagName("TEXTAREA");
      for (var intNum=0;intNum<objTags.length;intNum++)
            {
       objTags[intNum].readOnly = true;
            }
      */
        }catch(e) { alert(e.description); }
    }
    //防止Text输入非数字字符(int)
    function keyInputIntCheck()
    {
     try{
         if (window.event.keyCode<48 || window.event.keyCode>57)
            {
       if(window.event.keyCode!=45)
       {
        window.event.keyCode=0;
        return false;
       }
       /*else if(window.event.keyCode == 45)
       {
        var srcObj = window.event.srcElement;
        if((srcObj.tagName == "INPUT")&&(srcObj.type=="text"))
        {
         if(trim(srcObj.value)!="")
         {
          window.event.keyCode=0;
          return false;
         }
        }
       } */
            }
        }catch(e) { alert(e.description); }
    }

    //防止Text输入非正数字字符(int)
    function keyInputCorrecIntCheck()
    {
    try{
         if (window.event.keyCode<48 || window.event.keyCode>57)
            {
       if((window.event.keyCode!=45)||(window.event.keyCode!=46))
       {
        window.event.keyCode=0;
        return false;
       }
     
       /*else if(window.event.keyCode == 45)
       {
        var srcObj = window.event.srcElement;
        if((srcObj.tagName == "INPUT")&&(srcObj.type=="text"))
        {
         if(trim(srcObj.value)!="")
         {
          window.event.keyCode=0;
          return false;
         }
        }
       } */
            }
        }catch(e) { alert(e.description); }
    }
    //只允许输入正整数
    function keyInputPositiveInt()
    {
    try{
         if (window.event.keyCode>=48 && window.event.keyCode<=57)
            {
            }
            else
            {
       window.event.keyCode=0;
       return false;
            }
        }catch(e) { alert(e.description); }
    }
    //只允许输入正浮点数
    function keyInputPositiveFloat()
    {
    try{
         if ((window.event.keyCode>=48 && window.event.keyCode<=57) || window.event.keyCode==46)
            {
            }
            else
            {
       window.event.keyCode=0;
       return false;
            }
        }catch(e) { alert(e.description); }
    }
    //去掉字符串的空格
    function trim(str)
    {
     try {
      while(str.charCodeAt(0) == 32) {
       str = str.substr(1, str.length-1);
      }
      while(str.charCodeAt(str.length-1) == 32) {
       str = str.substr(0, str.length-1);
      }
      return(str);
     } catch(e) { throw e; }
    }
    //打开一个页面
    function OpenFarWindow(strPage)
    {
     try{
      window.open(strPage, "frmOperation","height=400,width=600,left=10000,top=10000,resizable=yes,status=yes,toolbar=no,menubar=no,location=no") ;
     } catch(e) { throw e; }
    }
    //创建Select标签的Option对象
    function CreateOptions(objField, strData, eachLength, innerText, value)
    {
     try{
      if (objField)
      {
       var arrData=strData.split("|");
       var intEachLength=parseInt(eachLength);
       var intInnerText=parseInt(innerText);
       var intValue=parseInt(value);

       var objOption,intNum;     

       for(intNum=0;intNum<arrData.length-1;intNum+=intEachLength)
       {
         objOption=document.createElement("OPTION");
         objField.options.add(objOption);
         objOption.innerText=arrData[intNum+intInnerText];
         objOption.value=arrData[intNum+intValue];      
       }
      }
     }catch(e) { throw e; }
    }

    var whitespace = " \t\n\r";

    //判断字符串或字符是否为空
    function isEmpty(s)
    {  
     return ((s == null) || (s.length == 0))
    }

    //判断是否为空格字符或字符串
    function isWhitespace (s)
    {
     var i;
     
     if (isEmpty(s)) return true;
     
     for (i = 0; i < s.length; i++)
     {
      var c = s.charAt(i);
     
      if (whitespace.indexOf(c) == -1) return false;
     }
     
     return true;
    }

    //保证输入了值
    function ForceEntry(objField, FieldName)
    {
     if (objField)
     {
      var strField;
      if(objField.TxtValue==null)
      {
       strField = new String(objField.value);
      }
      else
      {
       strField = new String(objField.TxtValue);
      }

      if (isWhitespace(strField))
      {
       alert("You need to enter information for " + FieldName);
       objField.focus();
       //objField.select();
      
       return false;
      }
     }
     
     return true;
    }


    //保证输入值为合法的货币数值
    function ForceMoney(objField, FieldName)
    {
     if (objField)
     {
      var strField;
      if(objField.TxtValue==null)
      {
       strField = new String(objField.value);
      }
      else
      {
       strField = new String(objField.TxtValue);
      }
     
      if (isWhitespace(strField)) return true;
     
      var i = 0;
     
      for (i = 0; i < strField.length; i++)
      {
       if (strField.charAt(i) == '.')
        ;
       else
       {
        if (strField.charAt(i) < '0' || strField.charAt(i) > '9')
        {
         alert(FieldName + " must be a valid numeric entry.  Please do not use commas or any non-numeric symbols.");
         objField.focus();
        
         return false;
        }
       }
      }
     }
     
     return true;
    }


    //保证输入值不含有非法字符
    function ForceNoInvalidChar(objField, FieldName)
    {
     if (objField)
     {
      var strField;
      if(objField.TxtValue==null)
      {
       strField = new String(objField.value);
      }
      else
      {
       strField = new String(objField.TxtValue);
      }
      var i = 0;
      for (i = 0; i < strField.length; i++)
      {
       if (strField.charAt(i) == "'")
       {
        alert(FieldName + " cannot contain apostrophes (').");
        objField.focus();
       
        return false;
       }
       if (strField.charAt(i) == ">")
       {
        alert(FieldName + " cannot contain right parenthesis (>).");
        objField.focus();
       
        return false;
       }
       if (strField.charAt(i) == "<")
       {
        alert(FieldName + " cannot contain left parenthesis (<).");
        objField.focus();
       
        return false;
       }
       if (strField.charAt(i) == "|")
       {
        alert(FieldName + " cannot contain vertical line (|).");
        objField.focus();
       
        return false;
       }
       if (strField.charAt(i) == "%")
       {
        alert(FieldName + " cannot contain percent (%).");
        objField.focus();
       
        return false;
       }
      }
     }
     
     return true;
    }

    //保证输入正确的Email地址
    function ForceEmail(objField, FieldName)
    {
     if (objField)
     {
      var strField;
      if(objField.TxtValue==null)
      {
       strField = new String(objField.value);
      }
      else
      {
       strField = new String(objField.TxtValue);
      }
      var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
      var regex = new RegExp(emailReg);
     
      if (regex.test(strField) != true)
      {
       alert(FieldName + " must be a valid email address.");
       objField.focus();
      
       return false;
      }
     }

     return true;
    }
    //格式化日期
    function formatDate(sDate) {
     var sScrap = "";
     var dScrap = new Date(sDate);
     if (dScrap == "NaN") return sScrap;
     
     iDay = dScrap.getDate();
     iMon = dScrap.getMonth();
     iYea = dScrap.getFullYear();
     
     iMon = iMon + 1;
     if (iMon<10) { iMon = '0' + iMon;}
     if (iDay<10) { iDay = '0' + iDay;}
     
     //sScrap = iYea + "/" + (iMon + 1) + "/" + iDay ;
     sScrap = iYea + "-" + iMon + "-" + iDay ;
     return sScrap;
    }
    //格式化浮点数
    function formatFloat(fltNum,intDesc){
     var i = intDesc ;
     var j = 1;
     while(i>0){
      fltNum = fltNum * 10 ;
      i = i - 1 ;
      j = j*10 ;
     } ;
     fltNum = Math.round(fltNum) ;
     fltNum = fltNum/j ;
     return fltNum ;

    }
    //定义实体数据状态对象
    function TEntityStatus()
    {
     /// 表明不存在于数据库表中
     this.New=0;

     /// 表明是来自于数据库表中
     this.FromDB=1;

     /// 被标记为需要UPdate到数据库中
     this.Update=2;

     /// 被标记为需要从数据库中Delete
     this.Delete=3;
    }
    //修正浮点数的精确度(bit:精确到的小数位数,strDecimal:浮点数)(参数必须是正确类型)
    //返回浮点数字符串,当小数位数不足时添零。
    function FormatDecimal(bit,strDecimal)
    {
    var i=0;
    //补零    
    var strFill="";
    //四舍五入后要加的数值
    var addDecimal="0.";             
    while(i<bit)
     {           
      strFill=strFill+"0";
      if(i==bit-1)
      {            
       addDecimal=addDecimal+"1";            
      }
      else
      {            
       addDecimal=addDecimal+"0";
      }         
      i=i+1;         
     } 
    i=0;          
    var beginPlace=strDecimal.indexOf('.');
     
    //判断此浮点数是否无小数部份
    if(beginPlace==-1)
    {
     if(bit==0)
     {
     //精确位数到个位           
      return strDecimal;                      
     }
     
     // 精确位数到个位,小数位数不足时添零      
     return strDecimal+"."+strFill;         
    }            
    var strDecimalC=strDecimal+strFill;
     
    var str= strDecimalC.split('.');      

    var strInt=str[0];      
    var strDecimal=str[1]+strFill;
    var IntDecimal=parseFloat("0."+strDecimal);       
    var validPlace=beginPlace+bit+1;
    var validData=strDecimalC.substring(validPlace,validPlace+1);      
     
    //进行四舍五入判断
    if(parseInt(validData)>4)
    {  
     if(bit==0)
      {
      //精确位数到个位            
      return parseInt(strInt)+1;                    
      }
     //精确到小数的位数
     var differents="0."+strFill+strDecimal.substring(bit,strDecimal.length);
     
     IntDecimal=IntDecimal-parseFloat(differents);
     
     IntDecimal=IntDecimal+parseFloat(addDecimal);
        
     var DecimalValue=parseInt(strInt)+IntDecimal; 
     strDecimalC=DecimalValue.toString(10)+strFill;   
    }
     
    //strDecimalC为重新得到的浮点数字符串 
    var beginPlace=strDecimalC.indexOf('.');
    //得到整数部分                   
    var beginStr=strDecimalC.substring(0,beginPlace);
    if(bit==0)
     {             
      return beginStr;            
     }
    //得到小数部分,删除多余小数位数      
    var EndStr=strDecimalC.substring(beginPlace,beginPlace+bit+1);    
    return beginStr+EndStr;              
    }
    //设置树,使不可用的节点仍然可以展开 Add Csynine Yang 2004.5.13
    function SetDisabledNodeExpand(treeId)
    {
       var roots = treeId.getNodes();
       for (var i=0; i<roots.length; i++)
       {     
           InitNode(roots[i]);
       }
    }
    function InitNode(node)
    {
        if (!node.getEnabled()) node.setEnabled(true);
        var leafs = node.getChildNodes();
        for (var j=0; j<leafs.length; j++)
        {
            InitNode(leafs[j]);
        }
    }
    function checkTxtObjIsNull(obj)
    {
     if((obj==null)||(trim(obj.value) == ""))
     {
      alert("该项不可为空");
      obj.focus();
      return false;
     }
     return true;
    }
    //记录扩展数据的时间值 Add By Csynine Yang 2004.8.26
    function CalendarEdit(t)
    {
     Calendar(t);
     RecordExpandData();
    }
    //记录扩展数据的改变值 Add By Csynine Yang 2004.8.20
    function RecordExpandData()
    {
     var strID = "";
     var ctrlID = document.getElementById("XPUC_ControlID");
     if (ctrlID==null)
     {
      ctrlID = igtab_getTabById("UWTDetail").findControl("XPUC:ControlID");
      if (ctrlID==null) return;
      else strID = ctrlID.value;
     }
     else
     {
      strID = ctrlID.value;
     }
     var ctrls = strID.split('|');
     var ctrlVal = document.getElementById("XPUC_ControlVal");
     if (ctrlVal==null)
     {
      ctrlVal = igtab_getTabById("UWTDetail").findControl("XPUC:ControlVal");
      if (ctrlVal==null) return;
     }
     ctrlVal.value = "";
     for (var i=0; i<ctrls.length; i++)
     {
      if (ctrls[i]=="") break;
      var ctrl = document.getElementById(ctrls[i]);
      ctrlVal.value += ctrls[i] + "/" + ctrl.value + "|";
     }
    }
    //设置扩展数据的改变值 Add By Csynine Yang 2004.8.20
    function RecoverExpandData()
    {
     var strID = "";
     var ctrlID = document.getElementById("XPUC_ControlID");
     if (ctrlID==null)
     {
      ctrlID = igtab_getTabById("UWTDetail").findControl("XPUC:ControlID");
      if (ctrlID==null) return;
      else strID = ctrlID.value;
     }
     else
     {
      strID = ctrlID.value;
     }
     var ctrls = strID.split('|');
     var ctrlVal = document.getElementById("XPUC_ControlVal");
     if (ctrlVal==null)
     {
      ctrlVal = igtab_getTabById("UWTDetail").findControl("XPUC:ControlVal");
      if (ctrlVal==null) return;
     }
     for (var i=0; i<ctrls.length; i++)
     {
      if (ctrls[i]=="") break;
      var ctrl = document.getElementById(ctrls[i]);
      ctrl.value = ctrlVal.value.split('|')[i].split('/')[1];
     }
    }
    //设置扩展数据的只读属性 Add By Csynine Yang 2004.8.24
    function ReadOnlyExpandData()
    {
     var strID = "";
     var ctrlID = document.getElementById("XPUC_ControlID");
     if (ctrlID==null)
     {
      ctrlID = igtab_getTabById("UWTDetail").findControl("XPUC:ControlID");
      if (ctrlID==null) return;
      else strID = ctrlID.value;
     }
     else
     {
      strID = ctrlID.value;
     }
     var ctrls = strID.split('|');
     for (var i=0; i<ctrls.length; i++)
     {
      if (ctrls[i]=="") break;
      var ctrl = document.getElementById(ctrls[i]);
     
      if(ctrl == null)continue;
      ctrl.disabled = true;
     }
    }
    //设置扩展数据的可写属性 Add By Csynine Yang 2004.8.24
    function RewriteExpandData()
    {
     var strID = "";
     var ctrlID = document.getElementById("XPUC_ControlID");
     if (ctrlID==null)
     {
      ctrlID = igtab_getTabById("UWTDetail").findControl("XPUC:ControlID");
      if (ctrlID==null) return;
      else strID = ctrlID.value;
     }
     else
     {
      strID = ctrlID.value;
     }
     var ctrls = strID.split('|');
     for (var i=0; i<ctrls.length; i++)
     {
      if (ctrls[i]=="") break;
      var ctrl = document.getElementById(ctrls[i]);
     
      if(ctrl == null)continue;
      ctrl.disabled = false;
     }
    }
    //检验输入小数类型的合法性 Add By Csynine Yang 2004.8.20
    function CheckDecimal(data)
    {
     if (data=="") { alert("请输入数据"); return 0; }
     
     if (isNaN(parseFloat(data))) { alert("请输入数值"); return 0; }
     
     //if (parseFloat(data)<0) { alert("请输入正数"); return 0; }
     
     return parseFloat(data);
    }
    //ClientCallback方法调用 Add By Csynine Yang 2004.10.8
    function scriptCallback(param, context, type)
    {
     var xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
     xmlhttp.Open('POST', 'http://' + context + '/Commons/Client Callback/RaiseCallback.aspx?type=' + type, false);
     xmlhttp.Send(param);
     return xmlhttp.responseText;
    }
     
    //测字符串实际长度(此方法会将一个汉字的长度认为是2,一个英文字符长度为1) Add By Simone Xu
    String.prototype.Tlength = function(){
     var arr=this.match(/[^\x00-\xff]/ig);
     return this.length+(arr==null?0:arr.length);}
     
    //字符串左取,用法如下 Add By Simone Xu
    // var str = 'abcdefghi';
    // str.left(5); //左截取结果为'abcde'
    // var allstr = '好好h好好h';
    // allstr.left(5);   //左截取结果为'好好h好好'
    // allstr.left(5,true); //左截取结果为'好好h'
    String.prototype.left = function(num,mode){
     if(!/\d+/.test(num))return(this);
     var str = this.substr(0,num);
     if(!mode) return str;
     var n = str.Tlength() - str.length;num = num - parseInt(n/2);
     return this.substr(0,num);}
     
    //字符串右取 Add By Simone Xu
    //用法同左截取
    String.prototype.right = function(num,mode){
     if(!/\d+/.test(num))return(this);
     var str = this.substr(this.length-num);
     if(!mode) return str;
     var n = str.Tlength() - str.length;num = num - parseInt(n/2);
     return this.substr(this.length-num);}
     

    //字符串去除两端空字符 Add By Simone Xu
    String.prototype.Trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");}
    //字符串去除左端空字符 Add By Simone Xu
    String.prototype.Ltrim = function(){return this.replace(/(^\s*)/g, "");}
    //字符串去除右端空字符
    String.prototype.Rtrim = function(){return this.replace(/(\s*$)/g, "");}

    //added by jessie lee
    function CheckCellValua(obj)
    {
     //alert(obj +" | " + obj.getValue());
     if(obj == null || obj.getValue() == null)
     {
      return "";
     }
     else
     {
      return obj.getValue();
     }
    }

    function ConfirmDelete()
    {
     if(confirm("是否确认删除?"))
      return true;
     else return false;
    }

    //父窗体自加
    function loadTxtInc(){
     if (parent.document.all.hidLoadTxt!=null){
      var i=parseInt(parent.document.all.hidLoadTxt.value);
      if (!isNaN(i)){
       i=i+1;
      }
      else{
       i=0;
      }
      parent.document.all.hidLoadTxt.value=i;
     }
    }

    //父窗体的父窗体自加
    function loadParentTxtInc(){
     if (parent.parent.document.all.hidLoadTxt!=null)
     {
      var i=parseInt(parent.parent.document.all.hidLoadTxt.value);
      if (!isNaN(i)){
       i=i+1;
      }
      else{
       i=0;
      }
      parent.parent.document.all.hidLoadTxt.value=i;
     }
    }

    function test(id,id2)
    {
     var grid = igtbl_getGridById(id);
     var rows = grid.SelectedRows ;
     if(igtbl_getLength(rows)>0)
     {
      for(var row in rows)
      {
       row.selected = false ;
      }
     }
     var cols = grid.SortedColumns ;
     for( var col in cols )
     {
      col.sorted = false ;
      col.SortIndicator = 0;
     }
     //grid.SortedColumns;
     grid.ActiveRow="";
     grid.setActiveRow(null);
     igtbl_clearSelectionAll(id);
    }

    function screenStyle(myform,IntHeight,IntWidth)
    {
         if(screen.width<'1024')
          {  
             if( IntWidth=="")
             {
             myform.style.width=1024;
          }
          else
          {
            myform.style.width=IntWidth;
          }
         
          if( IntHeight=="")
          {
            myform.style.height=768;
          }
          else
          {
             myform.style.height=IntHeight;
          }                   
          }
    }
     

    function CheckPasswordValid(pwd)
    {
     if(pwd.length<6)
     {
      alert("密码长度不可小于 6 位");
      return false;
     }

     var objRe3 = new RegExp("^([A-Za-z]+[0-9]+)|([0-9]+[A-Za-z]+)$");
     if(!objRe3.test(pwd))
     {
      alert("密码中必须由字母和数字组成");
      return false;
     }
     
     return true;
    }

    function DateToString(aDate)
    {
     var _aDate = new Date(aDate);
     if(!_aDate)return "";
     else return _aDate.getFullYear() + "-" + (_aDate.getMonth()+1)+ "-" + _aDate.getDate();
    }
    </script>

      <script language="javascript">
      
          function Init()
          {
        try
        {
         //==========================================
         //获得当前IE访问的站点名称,如:www.sina.com.cn:81
         //document.all.txtSiteHostName.value = "http://" + top.document.location.host;
         //==========================================
         //alert("当前桌面分辨率为 "+screen.width+"×"+screen.height);
         if(screen.width=='800')
         {
          PortalBody.scroll="yes";
         }
         else
         {
          PortalBody.scroll="no";
         }
         //创建eHR所需的权限session Added by Karron Qiu
         document.all.iframeeHR.src = document.all.txteHRSrc.value;
         //alert(document.all.iframeeHR.src);
         //============================================================
        
         //创建幻影报表可见性页面
         document.all.iframeMR.src = document.all.txtMRSrc.value;
         //============================================================
        
         var menu=igmenu_getMenuById("UltraWebMenu1");
         var objItems=menu.getItems();
         var itemCount = screen.width/80;
         if(objItems.length<itemCount)
         {
          document.all("tdLeft").style.display="none";   
          document.all("tdRight").style.display="none";
         
          var k=screen.width-objItems.length*80;
          for (var i=0;i<objItems.length;i++)
          {
           objItems[i].Element.noWrap="true";
           objItems[i].Element.style.width=80;
           //alert(objItems[i].getText());
           if (objItems[i].getText()=="")
           {
            objItems[i].Element.style.width=k+"";
            objItems[i].Element.style.visibility="hidden";
           }
          }
         }
         else
         {
          //显示左右按钮
          document.all("tdLeft").style.display="block";   
          document.all("tdRight").style.display="block";
          for (var i=0;i<objItems.length;i++)
          {
           objItems[i].Element.noWrap="true";
          }
          for (var i=10;i<objItems.length;i++)
          {
           objItems[i].Element.style.display="none";
          }

         }
         document.all.trMenu.style.display="block";
        }catch(e) { alert(e.description); }
         
          }
       var m=0;
       var n=0;
       function btnleft()
       {
        try{
         var menu=igmenu_getMenuById("UltraWebMenu1");
         var objItems=menu.getItems();
         if(objItems.length>10 && m+9<objItems.length)
         {
          objItems[m].Element.style.display = "none";
          objItems[m+9].Element.style.display="block";
          m++;
          n=m;
         }
        }catch(e) { alert(e.description); }
       }
      
       function btnright()
       {
        try{
         var menu=igmenu_getMenuById("UltraWebMenu1");
         var objItems=menu.getItems();
         if(objItems.length>10)
         {
          if (n!=0)
          {
           objItems[n-1].Element.style.display = "block";
           objItems[n+8].Element.style.display="none";
           n--;
           m=n;
          }
         }
        }catch(e) { alert(e.description); }
       }
      
        
       function ItemClick(mn, id)
       {
        try
        {
         var item = igmenu_getItemById(id);
         if (item.getTag()==null || item.getTag()=="undefined"||item.getTag()==""||item.getTag()=="|") return false;
         var arrVal = item.getTag().split("|");
         document.all.hidParams.value = arrVal[1];
         document.all.FrmPostParamsData.action=arrVal[0];
         document.all.FrmPostParamsData.submit(); 
         clickiFrmData(2);
         return false;       
        }catch(e){alert(e.description);}
       
       }
       //设定功能URL的方法
       function SetiFrmDataurl(/website/blog/strURL)
       {
        try
        {
         clickiFrmData(2);
         document.all.ifrmData.src="/website/blog/strURL";
        }catch(e){alert(e.description);}
       
       }
       //显示不同Frame的方法
       function clickiFrmData(varVal)
       {
        try
        {
         document.all.tdPortal.style.fontWeight="normal";
         document.all.tdFunction.style.fontWeight="normal";
         document.all.tdData.style.fontWeight="normal";
        
         if (varVal==0)
         {
          document.all.trPortal.style.display="block";
          document.all.trFunctioNavigate.style.display="none";
          document.all.trData.style.display="none";
          document.all.tdPortal.style.fontWeight="bold";
          //document.all.tdPortal.style.color="white";
          //document.all.tdFunction.style.color="black";
          //document.all.tdData.style.color="black";
         }
         else if (varVal==1)
         {
          document.all.trPortal.style.display="none";
          document.all.trFunctioNavigate.style.display="block";
          document.all.trData.style.display="none";
          document.all.tdFunction.style.fontWeight="bold";
          //document.all.tdFunction.style.color="white";
          //document.all.tdPortal.style.color="black";
          //document.all.tdData.style.color="black";
         }
         else
         {
          document.all.trPortal.style.display="none";
          document.all.trFunctioNavigate.style.display="none";
          document.all.trData.style.display="block";
          document.all.tdData.style.fontWeight="bold";
          //document.all.tdData.style.color="white";
          //document.all.tdPortal.style.color="black";
          //document.all.tdFunction.style.color="black";
         }
        }catch(e){alert(e.description);}
       
       }
       function ItemHover(mn, id, bOver)
       {
        var item = igmenu_getItemById(id);
       
        if(bOver)
         window.status = item.getText();
        else
         window.status = "";
        return false;
       }
       /*
       function statUserInfo()
       {
        window.status = "欢迎使用本系统";
        setTimeout("statUserInfo()",1000);
       }
       */
      
       //关闭IE进入退出页面,清理在线信息 Add by Gavin Li
       function ClearTrash()
       {
        var arrpath = document.location.pathname.split("/");
       
        if (event.clientX < 0 && event.clientY < 0)
         window.open("/"+arrpath[1]+"/LogOffSystem.aspx","退出系统","top=60000,left=60000,height=1,width=1,status=no,toolbar=no,menubar=no,location=no");
       }
      
      </script>

  • 相关阅读:
    在Oracle怎样查询表中的top10条记录
    Ant
    oracle 时间函数(sysdate)
    oracle 时间函数 (to_date)
    Maven仓库管理器
    数据库中select into from 和 insert into select的区别
    oracle 定时器简单用法
    oraclea 定时器
    XP Home Edition SP2 也可以装 Rational Rose 2003
    Unity3D动态天空之UniSky
  • 原文地址:https://www.cnblogs.com/cosiray/p/1551950.html
Copyright © 2011-2022 走看看