Posted By

pmw57 on 09/19/12


url javascript js querystring parameters params

Versions (?)

Who likes this?

3 people have marked this snippet as a favorite


Get URL Parameter

 / Published in: JavaScript

Code from updated so that most jslint issues are resolved, and updated the return to use a guard condition instead of a separate if statement.

  1. function getUrlParam(name) {
  2. var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
  3. return (results && results[1]) || undefined;
  4. }

Report this snippet  

You need to login to post a comment.