6

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

My Page name is test1.aspx, I used:

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

It's not working!

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Prasad Jadhav
  • 5,090
  • 16
  • 62
  • 80
  • possible duplicate of [How can I make a redirect page in jQuery/JavaScript?](http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript) – Alex May 15 '12 at 13:46

3 Answers3

14

window.location is an object. You need to access the href property on it, like this:

window.location.href="test1.aspx?user=abc&place=xyz";
Elliot Bonneville
  • 51,872
  • 23
  • 96
  • 123
2

If you need to send dynamic value, then

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

window.location.href = "test1.aspx?user=" + user + "&place=" + place;
zeebonk
  • 4,864
  • 4
  • 21
  • 31
Moddasir
  • 1,449
  • 13
  • 33
-1
window.location = "path page?user=" + $("#txtuser").val();
kleopatra
  • 51,061
  • 28
  • 99
  • 211
hadi.sh
  • 129
  • 1
  • 4