Need JS Help

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

Nathan

Carpe DiemVIP Member
Impact
61
Hey everyone :gl:

I'm using some JavaScript on one of my sites, and I am stuck on something.

Basically I have an external js file that is loaded on all my pages and handles some things that are done on every page. On certain pages, I need to be able to know what (whose) page it is. I have a folder with individual member pages that are all .php files. So what I want to do is get the URL of the current page, and check for part of the url (/members/CURRENTMEMBERSPAGE.php) so I know what page it is currently on.

So basically I need a way to check if something exists in the location object.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
Close
Thanks nasaboy. However I feel kind of stupid now, I just ended up using the match() method on my object. Seems to be working great :)

Code:
var currentPage = location.href;

if (currentPage.match('Phaethon'))
{
//My code
}
 
0
Close
Oh, that's a much better solution to your problem. Most definitely more efficient, codewise.
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back