可能重复:
在JavaScript中获取查询字符串值
如何在javascript中获取get变量?
我想在jquery函数中传递它.
function updateTabs(){
//var number=$_GET['number']; how can i do this?
alert(number);
$( "#tabs" ).tabs({ selected: number });
}
Run Code Online (Sandbox Code Playgroud)
gio*_*_13 46
var $_GET = {};
if(document.location.toString().indexOf('?') !== -1) {
var query = document.location
.toString()
// get the query string
.replace(/^.*?\?/, '')
// and remove any existing hash string (thanks, @vrijdenker)
.replace(/#.*$/, '')
.split('&');
for(var i=0, l=query.length; i<l; i++) {
var aux = decodeURIComponent(query[i]).split('=');
$_GET[aux[0]] = aux[1];
}
}
//get the 'index' query parameter
alert($_GET['index']);
Run Code Online (Sandbox Code Playgroud)
写:
var $_GET=[];
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(a,name,value){$_GET[name]=value;});
Run Code Online (Sandbox Code Playgroud)
然后 $_GET['number']
| 归档时间: |
|
| 查看次数: |
71823 次 |
| 最近记录: |