当前位置:起点学习辅导网培训频道电脑知识学习网页制作Javascript教程JavaScript校验函数库

JavaScript校验函数库

08-08 00:40:52浏览次数:889栏目:Javascript教程
标签:javascript视频教程,javascript教程下载, JavaScript校验函数库,
     obj = obj .offsetParent;   
   }   
return objLeft ;   
}   
  
// get absolute TOP position   
//建立者:jiarry@hotmail.com   
//返回对象位于窗口的绝对上边距离   
function getAbsoluteTop( ob ){   
if(!ob){return null;}   
var obj = ob;   
var objTop = obj .offsetTop;   
while( obj != null && obj .offsetParent != null && obj .offsetParent.tagName != "BODY" ){   
   objTop += obj .offsetParent.offsetTop;   
   obj = obj .offsetParent;   
}   
return objTop ;   
}   
  
// get absolute TOP position   
//建立者:jiarry@hotmail.com   
//检查颜色值是否为真;   
//用法: if( isAllNum16("#000000") )alert("合法颜色");   
function isNum16(ch)   
{   
  if (ch >= '0' && ch <= '9')return true;   
  if (ch >= 'A' && ch <= 'F')return true;   
  if (ch >= 'a' && ch <= 'f')return true;   
  return false;   
}   
function isAllNum16(str1)   
{//判断颜色值。除第一个字符#外的任一个值是否大于等a,A,0,小于等于f,F,9,否则报错。   
  for (i=1; i<str1.length; i++) {   
   if (!isNum16(str1.charAt(i)))   
   {   
    return false;   
   }   
  }   
  return true;   
}   
  
/**  
* Read the JavaScript cookies tutorial at:  
*   http://www.netspade.com/articles/javascript/cookies.xml  
*/  
  
/**  
* Sets a Cookie with the given name and value.  
*  
* name       Name of the cookie  
* value      Value of the cookie  
* [expires]  Expiration date of the cookie (default: end of current session)  
* [path]     Path where the cookie is valid (default: path of calling document)  
* [domain]   Domain where the cookie is valid  
*              (default: domain of calling document)  
* [secure]   Boolean value indicating if the cookie transmission requires a  
*              secure transmission  
*/  
function setCookie(name, value, expires, path, domain, secure)   
{//时间,域名,路径等可以根据需要来设定   
    //var path="/";   
//var domain="baidu.com";   
var expdate = new Date();   
expdate.setTime(expdate.getTime() + (365*24*120));//设为1年时效   
    expires = expdate;   
  
    document.cookie= name + "=" + escape(value) +   
        ((expires) ? "; expires=" + expires.toGMTString() : "") +   
        ((path) ? "; path=" + path : "") +   
        ((domain) ? "; domain=" + domain : "") +   
        ((secure) ? "; secure" : "");   
}   
  
function readCookie(name) {   
//http://www.quirksmode.org/js/cookies.html#link7   
var nameEQ = name + "=";   
var ca = document.cookie.split(';');   
for(var i=0;i < ca.length;i++) {   
  var c = ca[i];   
  while (c.charAt(0)==' ') c = c.substring(1,c.length);   
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);   
}   
return null;   
}   
/**  
* Gets the value of the specified cookie.  
*  
* name  Name of the desired cookie.  
*  
* Returns a string containing value of specified cookie,  
*   or null if cookie does not exist.  
*/  
function getCookie(name)   
{   
    var dc = document.cookie;   
    var prefix = name + "=";   
    var begin = dc.indexOf("; " + prefix);   
    if (begin == -1)   
    {   
        begin = dc.indexOf(prefix);   
        if (begin != 0) return null;   
    }   
    else  
    {   
        begin += 2;   
    }   
    var end = document.cookie.indexOf(";", begin);   
    if (end == -1)   
    {   
        end = dc.length;   
    }   
    return unescape(dc.substring(begin + prefix.length, end));   
}   
  
/**  
* Deletes the specified cookie.  
*  
* name      name of the cookie  
* [path]    path of the cookie (must be same as path used to create cookie)  

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]  下一页

,JavaScript校验函数库
《JavaScript校验函数库》相关文章
给资讯打分:
网友评论: