![](/img/trans.png)
[英]Passing Variable through JavaScript from one html page to another page
[英]Passing querystring from one page to another through javascript
我有两个不同的页面。 我想将查询字符串从一个发送到另一个。 以下是我尝试过的示例代码
window.location.search = 'id='+hidposid.value;
window.location.href="editviewposition.aspx";
在另一页中,我检索值
cookie1 = HttpContext.Current.Request.QueryString("id") ' returns ""
<script type="text/javascript">
$(function () {
$("#btnQueryString").bind("click", function () {
var url = "Page2.htm?name=" + encodeURIComponent($("#txtName").val()) + "&technology=" + encodeURIComponent($("#ddlTechnolgy").val());
window.location.href = url;
});
});
</script>
<input type="button" id="btnQueryString" value="Send" />
希望这对你有帮助。
我想我喜欢做类似的事情
window.location.href= 'editviewposition.aspx?id=' + hidposid.value;
还是有没有可能这样做的原因?
在这里,您传递的是查询字符串,而不是cookie。
window.location.search = '?id='+hidposid.value;
window.location.href="editviewposition.aspx";
然后在后面的代码中
HttpContext.Current.Request.QueryString("id")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.