Thursday, September 29, 2011

jQuery GET

jQuery:
function getQuerystring(key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}
var author_value = getQuerystring('author');

function changetoSpace($str){
$str= $str.replace("%20"," ");
return $str;
}

var a=unescape(author_value);

URL:
http://test.com?author=reyneil

OUTPUT:
reyneil

No comments:

Post a Comment