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

Use javascript to get the page name_javascript tips

WBOY
Release: 2016-05-16 16:24:51
Original
1161 people have browsed it

The code is very simple, so I won’t go into too much nonsense. Here is the code:

Copy code The code is as follows:

// Get the name of the current page (without suffix)
function getPageName1()
{
var a = location.href;
var b = a.split("/");
var c = b.slice(b.length-1, b.length).toString().split(".");
Return c.slice(0, 1);
}
//Get the current page name (with suffix)
function getPageName2()
{
var strUrl=location.href;
var arrUrl=strUrl.split("/");
var strPage=arrUrl[arrUrl.length-1];
Return strPage;
}
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template