0

The first technique that I can write the Query string is using the submit's form.

I want to change the url without the redirect.

Old Url is

localhost:8080

and automatically adding foo=1&foo=2 (variable s) in the Url

localhost:8080?=foo=1&foo=2

There are other technique or means for writing?

5
  • It is unclear what you're trying to ask. Are you asking how to change the query string without causing the browser to load a new page? Commented Mar 23, 2013 at 0:23
  • When you make a request to localhost:8080 there is no way to request localhost:8080?=foo=1&foo=2 without redirecting the browser unless you use some htaccess url rewriting Commented Mar 23, 2013 at 0:27
  • @jfriend00 excatly and I update the question Commented Mar 23, 2013 at 0:31
  • @HamZaDzCyberDeV How to use some htaccess url rewriting Commented Mar 23, 2013 at 0:33
  • 1
    afaik, it is not possible. only way i know is to use location.hash and replace whole content using ajax. then if user clicks refresh page with hash in the url, you have to intercept it as early as possbile and do same aforementioned injection. Commented Mar 23, 2013 at 1:28

1 Answer 1

4

You can manipulate the location url with the HTML5 history API. Unfortunately, this only works on proper browsers.

Alternately you could use hash (#) instead of question mark in the URL. In your case localhost:8080#foo=1&bar=1 using location.href = '#foo=1&bar=1'; for example.

Don't know if this is possible in your case though.

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

Comments