Posted By

uberdragon on 09/21/11


Tagged


Versions (?)

php's $_GET in javascript


 / Published in: JavaScript
 

Usage:

URL: http://test.com/?test=true

var test = $_GET['test'];

  1. var parts = window.location.search.substr(1).split("&");
  2. var $_GET = {};
  3. for (var i = 0; i < parts.length; i++) {
  4. var temp = parts[i].split("=");
  5. $_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
  6. }

Report this snippet  

You need to login to post a comment.