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.