使用JavaScript jQuery从网址获取GET变量 [英] Get GET variables from url using JavaScript jQuery
本文介绍了使用JavaScript jQuery从网址获取GET变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用jquery从网址中读取GET变量
I want to read out a GET variable from an url using jquery
域名显示如下
http://example.com/p/kT2Rnu35
原来是:
http://example.com/php/page.php?id=kT2Rnu35
我想从域 http://example.com/p的页面上使用jQuery获取该ID. /kT2Rnu35
我已经尝试过 window.location 和其他我在堆栈溢出时发现的功能,但是没有任何效果.是因为我正在使用 htaccess 更改网址吗?
I've tried window.location and other functions i found on stack overflow but nothing worked. Is it because i'm changing the url using htaccess ?
推荐答案
window.location.href
将为您提供带有参数的网址
window.location.href
will give you the url with parameters
从那里开始,只需使用.split即可将其分解
From there just use .split to break it apart
这篇关于使用JavaScript jQuery从网址获取GET变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文