更改查询字符串参数

时间:2013-04-28 13:15:40

标签: javascript jquery

应该怎么样?

var text = $(this).siblings("[type=text]").val();
document.location = "Default.aspx" + "?id=" + text + "&type=" + query;

1 个答案:

答案 0 :(得分:2)

该媒体资源的名称为window.location,而非document.location。此外,您可能希望使用encodeURIComponent转义这些值中的一个(或两个)。

window.location = "Default.aspx" +
    "?id=" + encodeURIComponent(text) +
    "&type=" + encodeURIComponent(query);