Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript - reload page with different QueryString

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...!!!

like image 484
Prasad Jadhav Avatar asked May 15 '12 13:05

Prasad Jadhav


2 Answers

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";
like image 76
Elliot Bonneville Avatar answered Sep 17 '22 22:09

Elliot Bonneville


If you need to send dynamic value, then

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

window.location.href = "test1.aspx?user=" + user + "&place=" + place;
like image 28
Moddasir Avatar answered Sep 20 '22 22:09

Moddasir