javascript 解析url参数(转)
<html>
<head>
<meta http-equiv="Content-Type" content="html/text; charset=utf-8"/>
<title>JS get Parameter</title>
<script src="resource/js/param.js" type="text/javascript"></script>
</head>
<body>
<table>
<tr>
<td><input type="text" name="user" /></td>
<td><input type="text" name="password" /></td>
<td><input type="text" name="sysno" /></td>
</tr>
</table>
</body>
<script type="text/javascript">
var LocString=String(window.document.location.href);
function getQueryStr(str){
var rs = new RegExp("(^|)"+str+"=([^\&]*)(\&|$)","gi").exec(LocString), tmp;
if(tmp=rs){
return tmp[2];
}
// parameter cannot be found
return "";
}
document.getElementById("user").value = getQueryStr("user");
document.getElementById("password").value = getQueryStr("password");
document.getElementById("sysno").value = getQueryStr("sysno");
</script>
</html>
转自http://ben-sin.javaeye.com/blog/197469,,,作者是谁,,,,,他没写
<head>
<meta http-equiv="Content-Type" content="html/text; charset=utf-8"/>
<title>JS get Parameter</title>
<script src="resource/js/param.js" type="text/javascript"></script>
</head>
<body>
<table>
<tr>
<td><input type="text" name="user" /></td>
<td><input type="text" name="password" /></td>
<td><input type="text" name="sysno" /></td>
</tr>
</table>
</body>
<script type="text/javascript">
var LocString=String(window.document.location.href);
function getQueryStr(str){
var rs = new RegExp("(^|)"+str+"=([^\&]*)(\&|$)","gi").exec(LocString), tmp;
if(tmp=rs){
return tmp[2];
}
// parameter cannot be found
return "";
}
document.getElementById("user").value = getQueryStr("user");
document.getElementById("password").value = getQueryStr("password");
document.getElementById("sysno").value = getQueryStr("sysno");
</script>
</html>
转自http://ben-sin.javaeye.com/blog/197469,,,作者是谁,,,,,他没写
版权声明:本文原创发表于 博客园,作者为 imbob,博客 http://imbob.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则视为侵权。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则视为侵权。