2

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);
1
  • 1
    What you have works, though .assign() isn't necessary (but it does work!). window.location.href = firstPart + query Commented Mar 29, 2013 at 17:32

2 Answers 2

2

Do it like this:

window.location.href = firstPart + query;
Sign up to request clarification or add additional context in comments.

Comments

0
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.