两个html页面间传值
Posted gxw123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了两个html页面间传值相关的知识,希望对你有一定的参考价值。
1.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>1.html</title>
</head>
<body>
<form action="2.html" name="one" method="get">
<input type="text" name="one" placeholder="请输入内容">
<input type="submit" value="Submit" />
</form>
</body>
</html>
--------------------------------------------------------------------------------------------------------------
2.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
</head>
<body>
<input id="aaa" style="display:block;width:200px;height:50px;" type="text">
<input type="btn" value="提交">
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
</body>
<script type="text/javascript" charset="uft-8">
function getParameter(param)
{
var aaa = document.getElementById(‘aaa‘);
var query = decodeURI(window.location.search);//获取当前路径?后的字符串 并解码
console.log(query);
var iLen = param.length;//3
var iStart = query.indexOf(param);//1
if (iStart == -1)
return "";
iStart += iLen + 1;//4
var va = query.substring(iStart);//截取参数
aaa.value = va;
}
$(document).ready(function () {
var one = getParameter(‘one‘);
});
</script>
</html>
以上是关于两个html页面间传值的主要内容,如果未能解决你的问题,请参考以下文章