# Javascript Redirect - need help quick

**URL:** https://boards.straightdope.com/t/javascript-redirect-need-help-quick/502492
**Category:** Factual Questions
**Created:** [July 9, 2009, 8:51pm UTC](https://boards.straightdope.com/t/javascript-redirect-need-help-quick/502492 "2009-07-09T20:51:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Swallowed\_My\_Cellphone](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Swallowed\_My\_Cellphone](https://boards.straightdope.com/u/Swallowed_My_Cellphone)
#### Post date: [July 9, 2009, 8:51pm UTC](https://boards.straightdope.com/t/javascript-redirect-need-help-quick/502492/1 "2009-07-09T20:51:19Z")

</div>

My co-worker goofed up something. We have a page that goes to:

flying.html and one that goes to swimming.html

My co-worker sent out an email that told the **flyers** to go to **swimming.html?id=fly**

Is there a javascript redirect that will let us forward ONLY the people who have the ending **?id=fly** to the flying.html page, but everyone else who is supposed to get to swimming.html will not be-redirected?

---

<div class="post-metadata">

### Author: ![FlightlessBird](https://avatars.discourse-cdn.com/v4/letter/f/cdc98d/32.png) [@FlightlessBird](https://boards.straightdope.com/u/FlightlessBird)
#### Post date: [July 9, 2009, 9:03pm UTC](https://boards.straightdope.com/t/javascript-redirect-need-help-quick/502492/2 "2009-07-09T21:03:59Z")

</div>

you can get the url in js using document.location and then do a substr on that to test the end of the url.  
javascript:alert(document.location.toString().substr(-15));  
the above code will tell you the last 15 chars in the url. (if you paste it into your location bar)  
You can change it to look for the last 6 cahrs and make sure it’s == to “id=fly”  
Good luck

---

<div class="post-metadata">

### Author: ![Swallowed\_My\_Cellphone](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Swallowed\_My\_Cellphone](https://boards.straightdope.com/u/Swallowed_My_Cellphone)
#### Post date: [July 9, 2009, 9:09pm UTC](https://boards.straightdope.com/t/javascript-redirect-need-help-quick/502492/3 "2009-07-09T21:09:52Z")

</div>

Oh, that’s helpful. We already have a Cookie script that ads “id=fly” automatically into a form field. I’ll see if I can modify it…
