87,984
社区成员
发帖
与我相关
我的任务
分享
<meta charset="utf-8">
<h1>search页</h1>
<input type="text" id="txt"><input type="button" id="btn" value="搜索">
<script type="text/javascript">
window.onload = function(){
var txt = document.getElementById("txt"),
btn = document.getElementById("btn");
btn.onclick = function(){
window.location.href = "result.html?keywords=" + txt.value;
}
}
</script>
2. result页面
<meta charset="utf-8">
<h1>result页</h1>
<input type="text" id="txt"><input type="button" id="btn" value="搜索">
<script type="text/javascript">
window.onload = function(){
var keyWords = window.location.search.split("=")[1],
txt = document.getElementById("txt");
txt.value = decodeURI(keyWords);
}
</script>