<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title>修改页面</title> <script type="text/javascript"> function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1);//去掉字符串里的 ? strs = str.split("&"); //将字符串str 根据 & 分割成多个字符串,并存入数组strs /* strs[0]="i=1"; strs[1]="name=james"; */ for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = strs[i].split("=")[1]; //theRequest.i=1 //theRequest.name="james"; } } return theRequest; } //注意:此时是在修改页面里 window.onload = function () { var paras = GetRequest(); //获得url中的参数对象(url中的每个参数都以 该返回值 属性的方式存在) //alert(paras.name); document.getElementById("txtId").value = paras.i; document.getElementById("txtName").value = paras.name; //alert(window.location.search);//代表 url 参数字符串 } </script></head><body>要修改的班级信息:<br /><input type="text" id="txtId" /><br /><input type="text" id="txtName" /></body></html>