retrieve values from a url


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

This makes it easy to retrieve certain value from a url with different values appended to it.


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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.