开发者

jQuery and $_GET

Let's say I have this url: www.example.com/test.php?page=4

How do开发者_StackOverflow中文版 i retrieve the value of $_GET['page'] with jQuery? o_O


Check out the jQuery Query String Object Plugin


If you don't have jQuery or you don't want to use a plugin, you can use this code from netlobo.com:

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 "";
  else
    return results[1];
}

then use it as follows:

var pageNumber = gup( 'page' );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜