AARoads Forum

Please login or register.

Login with username, password and session length

Author Topic: Web Programming Question for Highway Website  (Read 232 times)

cahwyguy

  • *
  • Offline Offline

  • Posts: 302
  • California Highway Guy

  • Age: 58
  • Location: Northridge, CA
  • Last Login: December 09, 2018, 11:21:10 PM
    • California Highways
Web Programming Question for Highway Website
« on: July 03, 2018, 10:27:29 AM »

There doesn't seem to be a better place for this.

Currently, over on cahighways.org, I group highways into groups of 8, e.g., 001-008.html . To get to an individual highway, you use 001-008.html#001 or 001-008.html#LR001 (for legislative routes). I'm thinking about moving to a single highway per page to reduce page size, but I don't want to break existing links.

I'd like to get a Javascript that I can put in each nnn-mmm.html file that could (a) take a #mmm if given, rewrite it as mmm.html or mmm.html#LRmmm , and then do an auto reload of that page, and (b) if no reference is given, just go to the first highway's page in the group of eight.

I still need to figure out how I want to rework the indexing, so this isn't immediate, but I'm old-school HTML, not an expert in Javascript (although I have a really thick book on my desk on the subject).

Daniel
Logged
Daniel - California Highway Guy ● Highway Site: http://www.cahighways.org/ ●  Blog: http://blog.cahighways.org/ ● Follow California Highways on Facebook: https://www.facebook.com/cahighways

kurumi

  • *
  • Offline Offline

  • Posts: 1468
  • Location: Cupertino, CA
  • Last Login: Today at 12:41:36 AM
    • kurumi.com
Re: Web Programming Question for Highway Website
« Reply #1 on: July 03, 2018, 11:41:47 AM »

This seems to be what you're looking for: https://stackoverflow.com/a/21198129

The script grabs the hash (the #mmm part) from the original location (request URL) and redirects to the proper page using window.location.replace().

The example uses an explicit old -> new map, but your naming convention looks systematic enough to derive the new URL without having to list the conversions.

(I grouped highways as well in the beginning and in hindsight realized I should have done individual pages from the start.)

Logged

TheArkansasRoadgeek

  • *
  • Offline Offline

  • Posts: 1013
  • The Dude

  • Age: 19
  • Location: Fort Smith, Arkansas
  • Last Login: December 09, 2018, 08:20:40 PM
Re: Web Programming Question for Highway Website
« Reply #2 on: July 03, 2018, 11:46:18 AM »

I would try one of the Stack Exchange forums I believe it is Stack Overflow.


iPhone
Logged
Well, that's just like your opinion man...

 


Opinions expressed here on belong solely to the poster and do not represent or reflect the opinions or beliefs of AARoads, its creators and/or associates.