Reading GET variables in Javascript


/ Published in: JavaScript
Save to your folder(s)

Function enables the reading of url appended variables. See URL for more information.


Copy this code and paste it in your HTML
  1. function getParameterByName(name) {
  2. var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
  3. return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  4. }

URL: http://gromitski.com/blog/get-variables-in-javascript/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.