Posted By

Bonky on 09/25/08


Tagged

regex url parse variables parameters


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

sulfurito


Get URL Parameters


 / Published in: JavaScript
 

URL: http://www.netlobo.com/url_query_string_javascript.html

  1. function gup( name )
  2. {
  3. name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  4. var regexS = "[\\?&]"+name+"=([^&#]*)";
  5. var regex = new RegExp( regexS );
  6. var results = regex.exec( window.location.href );
  7. if( results == null )
  8. return "";
  9. else
  10. return results[1];
  11. }

Report this snippet  

You need to login to post a comment.