name = "/www/web/lampym/index.php"; pos = name.lastIndexOf('/');//'/所在的最后位置' str = name.substr(pos+1)//截取文件名称字符串 url = name.substr(0,pos)//截取路径字符串 alert(str); alert(url);