Home > Javascript > Get Current Page Name using javascript

Get Current Page Name using javascript


The below function will give you the current page name by using javascript:

function GetCurrentPageName() {
//method to get Current page name from url.
//return page name in small .
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf(‘/’) + 1);
return sPage.toLowerCase()
}

now when using :

 

function OnLoad() {

if (GetCurrentPageName() == ‘home.aspx’) {

alert(‘i got current page name’);

}

Advertisements
  1. March 2, 2013 at 4:42 am

    Great goods from you, man. I have understand your stuff previous to and you’re just too excellent. I really like what you’ve acquired here, really like what you are stating and the way in which you
    say it. You make it enjoyable and you still
    care for to keep it smart. I cant wait to read much more from you.
    This is actually a wonderful website.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: