Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




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.

Share this article   |    Print    |    Article read by 24597 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: No related interview question