获取URL地址中的文件名和参数的javascript代码_javascript技巧

WBOY
Release: 2016-05-16 18:47:22
Original
976 people have browsed it
复制代码代码如下:

//获取页面文件名
function GetPageName()
{
var url=window.location.href;//获取完整URL
var tmp= new Array();//临时变量,保存分割字符串
tmp=url.split("/");//按照"/"分割
var pp = tmp[tmp.length-1];//获取最后一部分,即文件名和参数
tmp=pp.split("?");//把参数和文件名分割开
return tmp[0];
}
Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!