php's $_GET in javascript


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

Usage:

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

var test = $_GET['test'];


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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.