Home  >  Article  >  Web Front-end  >  Use javascript to get the page name_javascript tips

Use javascript to get the page name_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:24:511158browse

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;
}
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