码迷,mamicode.com
首页 > Web开发 > 详细

两个html页面间传值

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

标签:star   substr   ace   java   提交   app   name   search   console   

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页面间传值

标签:star   substr   ace   java   提交   app   name   search   console   

原文地址:https://www.cnblogs.com/gxw123/p/9483009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!