0

I want to put a query in a URL using JavaScript, how can I do that?

2
  • var foo = 'http://example.com?foo=bar' Commented Jun 26, 2015 at 14:57
  • 1
    possible duplicate of Append a param onto the current URL Commented Jun 26, 2015 at 15:02

2 Answers 2

1

Guess, document.location.search is what you're looking for

Sign up to request clarification or add additional context in comments.

Comments

0

This is simple:

location.href += '?ts=true';

Refer: Append a param onto the current URL

4 Comments

is there any away to add just one query? (instead of a infinite loop of queries)?
You should make your question clearer. Could you make some illustration examples?
to do something like this: original: server/myapp.php?id=10 what i want: server/myapp.php?id=10&enabled=true
I think this would be simple: window.location.href + '&enabled=true'

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.