Reputation: 1227
I am trying to send window.location to a variable, but my method doesn't seem to be working.
I have one variable that is the query called query and another caller firstPart. I concatenate them and am trying to sent window to that concatenated URL, but it doesn't seem to work.
Here is what I have so far:
var query = "hello";
var firstPart = "http://google.com/?=";
window.location.assign(firstPart + query);
Upvotes: 2
Views: 6314
Reputation: 5682
var query = "hello";
var firstPart = "http://google.com/?=";
window.location.href = firstPart + query;
More on window location here https://developer.mozilla.org/en-US/docs/DOM/window.location
Upvotes: 0
Reputation: 50563
Do it like this:
window.location.href = firstPart + query;
Upvotes: 2