|
1.javascript获取url中参数的函数:
- function getQueryVariable(variable)
- {
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars.split("=");
- if(pair[0] == variable){return pair[1];}
- }
- return(false);
- }
复制代码
2.实例:
- http://www.daimaren.com/index.php?nuber=100&image=logo.png
复制代码
3.函数调用:
调用getQueryVariable("nuber");//返回 "100"
调用getQueryVariable("image");//返回 "logo.png"
|
|