NameSilo

Need JS Help

Spaceship Spaceship
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
•••
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
•••
Oh, that's a much better solution to your problem. Most definitely more efficient, codewise.
 
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back