1

i want to send a url variable to 2nd page that contains links to a 3rd page. I want the 2nd page links to pickup the variable and append it to the link on that page. Then, when the user clicks on the link in that page the user is sent to the 3rd page carrying the variable along with it.

page 1 = a href="http://www.page1.html?aff=1234"

page 2 = a href="http://www.page3?aff=????"

so i need to have a script that will replace the ???? with "1234"

I can't use any server scripting-

appreciate any help

Brad
  • 11
  • 1

2 Answers2

0

You can access them using location.search.

Check out the very popular solution here:

JavaScript query string

You can easily switch pages by setting window.location. You can include query strings there which will be passed to the second page. For the target page, you can read location.search and extract the variable you want using the function provided in the link above.

Community
  • 1
  • 1
caleb
  • 1,579
  • 12
  • 12
0

On the 2nd page:

<a href="http://www.page3" id="aff">...</a>

and in its script:

document.getElementById('aff').href += location.search;
DaveS
  • 3,156
  • 1
  • 21
  • 31