a.html中有一个链接
1
<a href="b.html?x=2&y=3">进入b.html</a>
可以使用到js,如下:
a.htm:
1
2
3
4
<form action="b.htm" >
<input name="q" type="text" value="" />
<input type="submit" value="提交" id="" />
</form>
b.htm
<html>
<body>
<div id="qbox"></div>
<script type="text/javascript">
function getArgs() {
var args = {}
var query = location.search.substring(1)
// Get query string
var pairs = query.split("&")
// Break at ampersand
for(var i = 0i <pairs.lengthi++) {
var pos = pairs[i].indexOf('=')
// Look for "name=value"
if (pos == -1) continue
// If not found, skip
var argname = pairs[i].substring(0,pos)// Extract the name
var value = pairs[i].substring(pos+1)// Extract the value
value = decodeURIComponent(value)// Decode it, if needed
args[argname] = value
// Store as a property
}
return args// Return the object
}
var str =getArgs()
alert(str['q'])//和input的name对应取值,
document.getElementById("qbox").innerHTML = str['q']//然后赋值给DIV
</script>
</body>
</html>
希望能帮到你哦!
用服务器语言来获取传递的参数如a.html有如下组件<from action="b.html" method="post"><input type="text" value="aaaaa" name="txt"></form>那么你可以在b.html中用<%String Val=(String)request.getParameter("txt")out.print(Val)%>这样你就可以获取到a.html页面中的文本框组件的值aaaaa欢迎分享,转载请注明来源:内存溢出
评论列表(0条)