首页 > Web开发 > 详细

两个html页面间传值

时间:2018-08-15 18:21:15      阅读:188      评论:0      收藏:0      [点我收藏+]

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!