<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
//获取文件后缀名
var img_url="http://img63.ddimg.cn/2019/7/1/201907011732228982.jpg"
var dit=img_url.lastIndexOf(".");
var dit_img=img_url.substring(dit,img_url.length);
document.write(dit_img);// .jpg
var slash=img_url.lastIndexOf("/");
var slash_img=img_url.substring(slash+1,img_url.length);
document.write(slash_img);
</script>
</body>
</html>