AARoads Forum

Please login or register.

Login with username, password and session length
Advanced search  


New rules for political content in signatures and user profiles. See this thread for details.

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


  • *
  • Offline Offline

  • Posts: 365
  • California Highway Guy

  • Age: 59
  • Location: Northridge, CA
  • Last Login: September 19, 2019, 06:06:47 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 - California Highway Guy ● Highway Site: http://www.cahighways.org/ ●  Blog: http://blog.cahighways.org/ ● Follow California Highways on Facebook: https://www.facebook.com/cahighways


  • *
  • Offline Offline

  • Posts: 1573
  • Location: Cupertino, CA
  • Last Login: Today at 11:38:51 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.)



  • *
  • Offline Offline

  • Posts: 1039
  • The Dude

  • Age: 19
  • Location: Fort Smith, Arkansas
  • Last Login: August 16, 2019, 03:45:24 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.

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.