viphat
1/5/2015 - 2:46 AM

Lấy ra QueryString mà bạn muốn: http://domain.com/?a=1&b=2&c=3 >>> gup('c') trả về 3

Lấy ra QueryString mà bạn muốn: http://domain.com/?a=1&b=2&c=3 >>> gup('c') trả về 3

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return null;
  else
    return results[1];
}