Home >Web Front-end >JS Tutorial >How to get the file name in the URL using JS_javascript skills

How to get the file name in the URL using JS_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 19:27:07930browse

I encountered this problem when writing a function to adapt the size of images...
Haha, I won’t go into details about the problem. I encountered another stone on the way to solve it, which is how to use JS to get the file name of the image. .
After thinking about it for a long time, I finally wrote a function...
I saved it for the first time for future use


[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
<script> var a="http://www.jb51.net/html/images/logo.gif"; var b=a.split("/"); var c=b.slice(b.length-1, b.length).toString(String).split("."); alert("取得的文件名是:" + c.slice(0, 1)); </script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn