页面显示效果,如下图:
主页面代码:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <br> <br> <a href="jssendValue.html?id=test&user=xujinzhong&pwd=123456&uid=123456" target="_blank"  >>>> 点击跳转到下一个界面 >>></a> </body> </html>
跳转页面代码:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script language="javascript"> var myID = "id" var myuser = "user" var mypwd = "pwd" var myuid = "uid" function getParameter(param) { var query = window.location.search; //获取URL地址中?后的所有字符 var iLen = param.length; //获取你的参数名称长度 var iStart = query.indexOf(param); //获取你该参数名称的其实索引 if(iStart == -1) //-1为没有该参数 return ""; iStart += iLen + 1; var iEnd = query.indexOf("&", iStart); //获取第二个参数的其实索引 if(iEnd == -1) //只有一个参数 return query.substring(iStart); //获取单个参数的参数值 return query.substring(iStart, iEnd); //获取第二个参数的值 } function init() { document.getElementById("id").value = getParameter(myID); document.getElementById("user").value = getParameter(myuser); document.getElementById("pwd").value = getParameter(mypwd); document.getElementById("uid").value = getParameter(myuid); } </script> </head> <body onload="init()"> this is a test <br> <input id="id" type="text" /> <br> <input id="user" type="text" /> <br> <input id="pwd" type="text" /> <br> <input id="uid" type="text" /> </body> </html>