您的位置:首页 > Web前端 > JavaScript

js页面传值的实现

2015-08-05 16:29 573 查看
<pre name="code" class="html"><html>
<head>
<title页面之间传值</title>
<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="js/jquery.params.js" type="text/javascript"></script>
<script type="text/javascript">
function winlocation () {

//1.var arr="wawaw";
//1.var url="chuanzhi2.jsp?value="+arr+"&val=haha"
//1.window.location.href=url;
//2.window.open("chuanzhi2.jsp");
//3.document.cookie="value=wawa"
//3.window.location.href="chuanzhi2.jsp"
/*
1.拼凑url,跳转到url,在跳转页面中$.query.get("value");需要导入jquery.params.js
2.传递控件的值:在跳转页面中$("#text").val(window.opener.document.getElementById("旧页面控件id").value);
3.cookie:旧页面设置cookie值,新页面获取document,cookie.xxxxx(传多个key/value还需改进
*/

}

</script>
</head>
<body>
<button onclick="winlocation()">location</button>
<input type="text" id="textt"></input>
<br>
<br>
</body>
</html>


<html>
<head>
<title页面之间传值</title>
<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="js/jquery.params.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
//1.var value=$.query.get("value");
//1.$("#text").val(value);
//2.$("#text").val(window.opener.document.getElementById("textt").value);
//3.$("#text").val(document.cookie.split("=")[1]);
});
</script>
</head>
<body>
<input type="text" id="text"></input>
<br>
<br>
</body>
</html>



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: