Js解析URL参数
抱雪
posted @ 2012年7月17日 23:52
in HTML/JS/CSS
, 6089 阅读
function getQueryStr(str){ var url=location.href; var rs = new RegExp("(^|)"+str+"=([^\&]*)(\&|$)","gi").exec(url), tmp; if(tmp=rs){ return tmp[2]; } // parameter cannot be found return ""; }
function parseUrl(){ var url=location.href; var i=url.indexOf('?'); if(i==-1)return; var querystr=url.substr(i+1); var arr1=querystr.split('&'); var arr2=new Object(); for (i in arr1){ var ta=arr1[i].split('='); arr2[ta[0]]=ta[1]; } return arr2; }
2023年11月02日 16:29
Hello, you used to write excellent, but the last few posts have been kinda boring… I miss your tremendous writings. Past few posts are just a little bit out of track! You’re brilliant! Thank you! I experience the beneficial data you offer for your articles. Fantastic blog! I dont assume ive visible all the angles of this situation the way youve pointed