- 博客(0)
- 资源 (1)
- 收藏
- 关注
JaswqvaScript 公共类
1 原生JavaScript实现字符串长度截取
function cutstr str len {
var temp;
var icount 0;
var patrn [^ x00 xff] ;
var strre "";
for var i 0; i < str length; i++ {
if icount < len 1 {
temp str substr i 1 ;
if patrn exec temp null {
icount icount + 1
} else {
icount icount + 2
}
strre + temp
} else {
break
}
}
return strre + " "
}
2 原生JavaScript获取域名主机
function getHost url {
var host "null";
if typeof url "undefined" || null url {
url window location href;
}
var regex ^ w+ : [^ ] ;
var match url match regex ;
if typeof match "undefined" && null match {
host match[1];
}
return host;
}"> 1 原生JavaScript实现字符串长度截取
function cutstr str len {
var temp;
var icount 0;
var patrn [^ x00 xff] ;
var strre "";
for var i 0; i < str length; i++ {
if icount < len 1 {
temp str substr i 1 ;
[更多]
2013-11-11
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅