JAVASCRIPT 39
$_GET function for javascript By timo on 18th January 2019 05:28:53 PM
  1. function $_GET(param) {
  2.         var vars = {};
  3.         window.location.href.replace( location.hash, '' ).replace(
  4.                 /[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
  5.                 function( m, key, value ) { // callback
  6.                         vars[key] = value !== undefined ? value : '';
  7.                 }
  8.         );
  9.  
  10.         if ( param ) {
  11.                 return vars[param] ? vars[param] : null;       
  12.         }
  13.         return vars;
  14. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.