![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JavaScript
yuzhangqu
这个作者很懒,什么都没留下…
展开
-
用JavaScript去除字符串的首尾空格。
String.prototype.Trim=function(){ returnthis.replace(/(^/s*)|(/s*$)/g,""); }String.prototype.LTrim=function(){ returnthis.replace(/(^/s*)/g,""); } String.prototype.RTrim=function转载 2010-02-04 08:43:00 · 366 阅读 · 0 评论 -
用JavaScript检查文件是否存在
function checkImgAddr(url){ var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("post",url,false); xmlhttp.send(); if(xmlhttp.readyState==4){ if(xmlhttp.st转载 2010-02-04 08:47:00 · 950 阅读 · 0 评论 -
用JavaScript获取QueryString(未测)
function QueryString(fieldName){ var urlString = location.search; if (urlString != null) { var typeQu = fieldName + "="; var urlEnd = urlString.indexOf(typeQu); if (urlEnd != -1) { va原创 2010-02-04 09:02:00 · 581 阅读 · 0 评论 -
用JavaScript截取一定长度字符串(中文长度为2,英文长度为1)
function mySubstr(str, len){ str = str.replace(/(^/s*)|(/s*$)/g, ""); var newLength = 0; var newStr = ""; var chineseRegex = /[^/x00-/xff]/g; var singleChar = ""; var strLength = str.repl转载 2010-02-04 08:52:00 · 763 阅读 · 0 评论