doulongti5932 2011-11-15 20:49
浏览 23

在Javascript中模仿$ _GET [重复]

Possible Duplicate:
Get query string values in JavaScript
Parse query string in JavaScript
Storing php $_GET variable in a javascript variable?

How can I mimic $_GET in JavaScript, and display the value of the $_GET, so: how can I do this kind of thing in JavaScript:

if($_GET['id'] == 1)
{
    //Do something
}
  • 写回答

3条回答 默认 最新

  • dpw43061 2011-11-15 20:54
    关注

    Could always use document.location.href to do this.

    Something like:

    var url = document.location.href, get;
    get = url.split('?');
    get = get.split('&');
    

    Which will leave you with an array of the $_GET variables. Hope that helps.

    评论

报告相同问题?