Pages

Saturday, March 29, 2014

Find Current Page URL and Check Page Exist or Not + JavaScript

Use : You can find out the current page url through javascript code and also you can check that the page is exist or not. If you found the page then you can take the action.
var currentPageUrlIs = "";
// Find out current Page URL
if (typeof this.href != "undefined") 
{
        currentPageUrlIs = this.href.toString().toLowerCase();
} 
else 
{
      currentPageUrlIs = document.location.toString().toLowerCase();
}
    
//Check Same Page Exist or Not
 if (currentPageUrlIs.indexOf("testpage") != -1) {
         //Action Time
 }
 else {
        // Do Something
 }

No comments:

Post a Comment