Get URL parameter


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



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.