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

在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.

    评论

报告相同问题?

悬赏问题

  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效