Posted By

mmstudio on 12/03/10


Tagged

url parameter


Versions (?)

Get URL parameter


 / Published in: JavaScript
 

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

Report this snippet  

You need to login to post a comment.