0

How do I add a query string value to a URL, then refresh that page?

The current url looks like: /foo/bar

I want to reload as /foo/bar?tabIndex=4

    function onSomethingComplete() {

    window.location.search = "tabIndex=4";
    window.location.reload();

}

Thanks!

2
  • window.location.href += "tabIndex=4"; Commented Feb 5, 2014 at 19:04
  • window.location.search already does a reload itself. Commented Feb 5, 2014 at 19:07

1 Answer 1

1

Should be able to do something like this:

function onSomethingComplete() {

    var url = window.location
    url += "?tabIndex=4"
    window.location = url

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

1 Comment

as long as I added the window.location.search; it worked, thanks!

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.