AJAX传参,JS获取当前URL参数(超级实用)
2016-12-22 00:00
453 查看
t.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> <script type="text/javascript"> var getParam = function(name){ var search = document.location.search; var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g"); var matcher = pattern.exec(search); var items = null; if(null != matcher){ try{ items = decodeURIComponent(decodeURIComponent(matcher[1])); }catch(e){ try{ items = decodeURIComponent(matcher[1]); }catch(e){ items = matcher[1]; } } } return items; }; window.onload=function(){ alert(getParam('ids')); alert(getParam('cid')); } </script> </head> <body> <h1>111111111</h1> </body> </html>
相关文章推荐
- AJAX传参,JS获取当前URL参数(超级实用)
- AJAX传参,JS获取当前URL参数(超级实用)
- js获取当前Url网址路径及参数 location.hostname
- js 获取当前url参数
- js javascript 获取url,获得当前页面的url,静态html文件js读取url参数
- js获取或设置当前窗口url参数的小例子
- js获取当前url地址及参数
- js获取当前url的参数
- js 获取当前url参数
- js获取当前url参数
- js javascript 获取url,获得当前页面的url,静态html文件js读取url参数
- js获取当前url的参数值
- js 获取当前url所带参数
- .net的ajax中使用javascript的send方法post参数,url传参,ajax同步异步JS包,传参即可用
- js javascript 获取url,获得当前页面的url,静态html文件js读取url参数
- js javascript 获取url,获得当前页面的url,静态html文件js读取url参数
- JS获取当前URL参数参数值
- JS获取当前/指定URL参数
- html页面中js获取当前url下指定参数的值
- js 获取当前url的参数