javascript - How to extract the parameter value from the url? -
response.sendredirect("http://localhost:8080/cse/welcome.html?first=fname&last=lname&dname=dept&mname=mobno");
how extract first,last,dname,mname parameters url , want use extracted values in redirected html document(welcmoe.html). how can achieve this?
if wanted client side using js, following.
//create array query strings //such ['first=fname', 'last=lname', ...] var querystring = location.search.substring(1).split("&"); var props = {}; //loop thru array querystring.foreach(function(item) { //split each item var item = item.split("="); //set first part key , last/second part value props[item.shift()] = item.pop(); }); alert ("first: " + props["first"]); alert ("last: " + props["last"]); //and on...
Comments
Post a Comment