js 获取字符串的后缀
2022-07-25 17:06:08 来源:admin 点击:550
var fileName = "http://www.111cn.net/sys/nginx/62888.htm";方法1
var fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);
或者 var strtype=strFileName.substring(strFileName.length-3,strFileName.length);
strtype=strtype.toLowerCase();
方法2
var fileExtension = fileName.split('.').pop().toLowerCase();
方法3
var str=document.getElementById("FileUpload1").value; var pos = str.lastIndexOf("."); var lastname = str.substring(pos,str.length)