Analyzing GET request with JavaScript

GET requests (using address bar) can be easily analyzed with JavaScript. I’ll demonstrate this with the following example: write in the address bar any parameter in the format ?parameter=value¶meter=value...
Variables of the GET request:
var tmp = new Array(); // two auxiliary var tmp2 = new Array(); // arrays var param = new Array(); var get = location.search; // string of the GET request if( get != '' ) { tmp = ( get.substr( 1 ) ).split( '&' ); // split variables for( var i=0; i < tmp.length; i++ ) { tmp2 = tmp[ i ].split( '=' ); // array param will contain param[ tmp2[ 0 ] ] = tmp2[ 1 ]; // param key(name of the variable)->value } var obj = document.getElementById( 'greq' ); // screen output for( var key in param ) { obj.innerHTML += key + " = " + param[ key ] + "<br>"; } }
The key value is location.search (see article on base tag).