Javascript - 使用不同的 QueryString 重新加载页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10602076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 10:25:07  来源:igfitidea点击:

Javascript - reload page with different QueryString

javascriptjavascript-events

提问by Prasad Jadhav

I want to reload a page using JavaScript passing different parameters in URL.

我想使用 JavaScript 在 URL 中传递不同的参数来重新加载页面。

My Page name is test1.aspx, I used:

我的页面名称是 test1.aspx,我使用了:

window.location="test1.aspx?user=abc&place=xyz";

It's not working...!!!

它不起作用......!

回答by Elliot Bonneville

window.locationis an object. You need to access the hrefproperty on it, like this:

window.location是一个对象。您需要访问其href上的属性,如下所示:

window.location.href="test1.aspx?user=abc&place=xyz";

回答by Moddasir

If you need to send dynamic value, then

如果您需要发送动态值,则

var user = "abc";
var place = "xyz";

window.location.href = "test1.aspx?user=" + user + "&place=" + place;

回答by hadi.sh

window.location = "path page?user=" + $("#txtuser").val();