0

I have a page here:

http://recipehappy.com/share.php?user=Mains&PID=2&passkey=bmAjWDMwmWcOBLoU4B0q2NARCG0PBTc1

I need to get the PID value and passkey value into JavaScript variable on the page. This may be simple, but I'm blocked.

Thanks for any help.

wibberding
  • 815
  • 3
  • 10
  • 17

1 Answers1

1

This is what I use

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

ex: getParameterByName('PID')

Source: https://stackoverflow.com/a/901144/643761

Community
  • 1
  • 1
Simcha Khabinsky
  • 1,970
  • 2
  • 19
  • 34