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页面间传值
原文地址:https://www.cnblogs.com/gxw123/p/9483009.html