0

Is that even possible?

As an example, the Main Menu page in this site is:

https://my.domain.com/WEPROD/WebProcess?TOKENIDX=5647385647&type=M&constituency=WBST&pid=MAIN-WBST

and a page:

https://my.domain.com/WEPROD/WebProcess?TOKENIDX=5647385647&SS=1&APP=ST&CONSTITUENCY=WBST

5647385647&SS is my token. It won't work for other users. So the link would need to somehow capture the token id portion dynamically from the current session or else users would be asked to log in again

btw- I can't just omit the token or I would mess things up later

  • Are you using any server-side code? Or do you need to do this using only JavaScript? – showdev Aug 10 '17 at 19:06
  • 1
    Possible duplicate of [How to get the value from the GET parameters?](https://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-get-parameters) – showdev Aug 10 '17 at 19:09

1 Answers1

0

You can get the querystring with location.search So the following would give you a map of all key-value pairs in the querystring, from which you can extract the token:

const queryArgs = new Map(
  location.search
    .substring(1) //get rid of the '?' at the start
    .split('&') //split into key-value pairs
    .map(pair => pair.split('=')) //make each key-value pair into [key, value]
)
console.log(queryArgs.get('TOKENIDX')) //'5647385647'
csander
  • 1,385
  • 10
  • 11