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);     
        alert(PageName);
< /script>

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



http://
http://

Contributed by:
Rohit kakria
I am software developer

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=324

Click here to go on website