得到文件名和目录名
程序员文章站
2022-04-18 17:19:26
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>filename</title>
</head>
<body>
<script>
name = '/www/web/lampym/index.php';
pos = name.lastIndexOf('/');
alert(name.substr(pos+1));//左闭右开
alert(name.substr(0,pos));
</script>
</body>
</html>