0

I have a subdomain that's dedicated to redirecting traffic that hits it.

The URL should always be similar to this: http://test.example.com/12345/

I'm trying to figure out how to get 12345 and assign that to a javascript variable.

If that directory isn't set or it isn't numeric (so there's nothing to set the variable to), I'd prefer to just set the variable to 11111.

I've read a few answers on StackOverflow saying that similar can't be done with pure javascript, which seems odd to me. But then again, I'm certainly no expert...

UPDATE: I understand that pathname can be used to get the path itself, but I'm not sure how to remove the trailing / and verify that it's numeric.

Chase
  • 115
  • 2
  • 8

0 Answers0