取值
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>取值</title> </head> <body> <input type="text" id="question" /><button id="btn">查询</button> <div id="answer"></div> </body> </html> <script type="text/javascript"> //var ss=document.location; var answer=document.getElementById("answer"); var oBtn=document.getElementById("btn"); var oInput=document.getElementById("question"); var str="http://localhost/?id=123&name=test&psw=aaa"; var r=str.substring(str.indexOf("?")+1); var arr=r.split("&"); oBtn.onclick=function(){ if(oInput.value.length>0 ){ for(var i=0;i<arr.length;i++){ if(arr[i].indexOf(oInput.value)==0){ answer.innerHTML=arr[i].slice(oInput.value.length+1); return; } } } } </script>