Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Need JS Help

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Parking: find your domains by pasting a list
You can now paste a list of domain names into the search box at the top of the Parking menu. Put one name on each line. Your domain list...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back