Xpode.com        Click here to Print this article.

Get the page name from browser url in javascript

To get the page name in web page. need to write window.location.

Complete code is given below:

< script language="javascript">
        var URL = window.location.pathname;
        var PageName = URL.substring(URL.lastIndexOf('/') + 1);     
< /script>

In this code, first we are fetching the url and then extracting the string after last "/" character.


Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com

Click here to go on website