Code:


/*

截取url字符串中的指定长度字符

strurl is url string, len is a number

eg. alert(strurlsub("http://XXXXXXXX/XXXXX/sdf中文sdfsdf.rar",7));

*/

function strurlsub(strurl,len){

var a,strname;

a = strurl.lastIndexOf("/");

strname = strurl.substring(a+1,strurl.length);


if(strname.length<=len){

return strname;

}else{

return strname.substring(0,len)+"...";

}


}