JS- intercept file name or path

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

Here Insert Picture Description
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_41998682/article/details/91820187