Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 19:27:07
Original
881 people have browsed it

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>
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template