Argument-Handling in JavaScript

Argument-Handling of a GET request (e.g. from a FORM) via JavaScript

Sample-Call: js-arguments-handling.php?name=Volker%20Tanger&email=volker.tanger@wyae.de


read URL

Code sample:
  mainURL = window.location.search;
  document.write("mainURL = "+mainURL);
  



Result:
 
  


URL dissection

Code sample:
  URLparts = mainURL.split('?');
  document.write("Arguments = "+URLparts[1]);
  



Result:
  
  


Parameter dissection

Code sample:
  Arguments = URLparts[1].split('&');
  for (i in Arguments) 
      document.write("Argument "+i+" = "+Arguments[i]+"<p>");
  



Result:
  
  


Further arguments dissection

Code sample:
  for (i in Arguments) {
	pair = Arguments[i].split('=');
  	document.write("Parameter: "+pair[0]+"<br>");
  	document.write("Value    : "+pair[1]+"<p>");
  }
  



Result: