PHP Javascript包括URL中的所有页面

I have a script that uses the page url. Depending on this URL, the navigation menu will be loaded differently. For example on the home page,

if(document.URL=="http://localhost/index.php")
  {
   //Adjust the menu for the home page;
  }

However, if you are on any page located in 'folder' below, the menu should be adjusted differently.

if(document.URL=="http://localhost/folder/page.php")
  {
   //Adjust the menu for a page in 'folder';
  } 

Is there a way I can include all pages under 'folder' in this script? Like:

if(document.URL=="http://localhost/folder/*") //include everything with *
  {
   //Adjust the menu for every page under 'folder';
  }

Thanks in advance

You can use indexOf:

if(document.URL.indexOf("http://localhost/folder/") == 0) {
    // We are in a page in or under folder
}
if(location.href.indexOf("http://localhost/folder/") == 0) {
    // We are in a page in or under folder
}

This should help