/ Published in: JavaScript
Simulate the $_GET array from php in javascript to get url parameters this way:
url= http://localhost/?var1=example
$_GET['var1'] will return "example"
Just copy and paste the code.
url= http://localhost/?var1=example
$_GET['var1'] will return "example"
Just copy and paste the code.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var $_GET=new function(){ var fullUrl=window.location.href.split('?'); var urlParams=fullUrl[1].split('&'); $_GET=new Array(); for(i=0;i<=urlParams.length-1;++i){ var param=urlParams[i].split('='); var name=param[0]; var value=param[1]; $_GET[name]=value; } return $_GET; }