纯HTML页面之间传递参数
2011-03-30 15:49
288 查看
<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>
通过test.html?user=abc&password=123&sysno=001的测试结果来看,截获参数的目的达到了
<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>
<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>
通过test.html?user=abc&password=123&sysno=001的测试结果来看,截获参数的目的达到了
相关文章推荐
- 后端往前段传递参数,大部分人都清楚,无非就是发起ajax请求获取后端值,然后通过js写入html相应位置即可。但是前段html页面之间,怎么传递参数呢?
- 静态页面html之间传递中文参数出现乱码问题的解决方案
- 前端在html页面之间传递参数的方法
- 前端在html页面之间传递参数的方法
- Jquery在两个HTML页面之间传递参数
- 前端在html页面之间传递参数的方法
- 用javascript实现html页面之间的参数传递的四种方法
- 纯HTML页面之间传递参数
- js jquery 实现html页面之间参数传递(单一参数、对象参数传递)
- 用javascript实现html页面之间的参数传递的四种方法
- 用javascript实现html页面之间的参数传递
- 【传递参数】html页面之间也可以传递参数
- 用javascript实现html页面之间的参数传递
- 如何使用js来实现通过href完成多个html页面之间的传递参数
- javascript实现html页面之间参数传递的四种方法实例分析
- javascript实现html页面之间参数传递的四种方法实例分析
- iframe之间静态html页面如何传递参数?
- 用javascript实现html页面之间的参数传递的四种方法
- 纯html页面之间传递参数
- 用javascript实现html页面之间的参数传递