Skip to content

Instantly share code, notes, and snippets.

@dangvanthanh
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save dangvanthanh/ed5ee3fa936a6f947bc9 to your computer and use it in GitHub Desktop.

Select an option

Save dangvanthanh/ed5ee3fa936a6f947bc9 to your computer and use it in GitHub Desktop.

Revisions

  1. dangvanthanh revised this gist Oct 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion app.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    * Get URL Parameters Using JavaScript
    */
    function getQueryParameters(qs) {
    qs = qs.replace(/[\[], '\\\[').replace(/[\]], '\\\]');
    qs = qs.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]');

    var regexPattern = '[\\?&]' + qs + '=([^&#]*)';
    var regex = new RegExp(regexPattern);
  2. dangvanthanh created this gist Oct 8, 2014.
    14 changes: 14 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    /**
    * Get URL Parameters Using JavaScript
    */
    function getQueryParameters(qs) {
    qs = qs.replace(/[\[], '\\\[').replace(/[\]], '\\\]');

    var regexPattern = '[\\?&]' + qs + '=([^&#]*)';
    var regex = new RegExp(regexPattern);

    var location = window.location.href;
    var results = regex.exec(location);

    return results == null ? null ? results[1];
    }