0

i use Javascript(AJAX) and want to change the addressbar Ex: http://mywebsite.com to http//mywebsite.com?web=info

cdxf
  • 5,501
  • 11
  • 50
  • 65

2 Answers2

3

you can not change the url without the page actually redirecting. You can however append a hashtag to the url.

http://mywebsite.com to http://mywebsite.com#something

See this question on StackOverflow.

Attaching hashtag to URL with javascript

Community
  • 1
  • 1
jhanifen
  • 4,441
  • 7
  • 43
  • 67
  • No, i don't want to change hash, just ?web=info – cdxf Oct 03 '10 at 01:23
  • @jhanifen : a "hashtag"? Isn't that something used in twitter? I believe in URLs that is called an anchor – Hogan Oct 03 '10 at 01:24
  • Well obviously twitter has made the term hashtag associated with a tweet. But #something in a url is also referred to as a hashtag. – jhanifen Oct 03 '10 at 01:27
  • @Snoob - You can not add ?web=info to the url without the page actually changing. If you don't mind the page changing then @Hogan's answer below is correct. – jhanifen Oct 03 '10 at 01:28
  • This isn't true anymore, at least in webkit (and others as they evolve), see this question: http://stackoverflow.com/questions/3849758/what-is-this-technology-facebook – Nick Craver Oct 03 '10 at 13:56
  • If you are only supporting "Good" browsers then that is definitely a possibility. – jhanifen Oct 03 '10 at 16:27
1

You don't want ajax just do this:

window.location = "http://mywebsite.com?web=info";
Hogan
  • 69,564
  • 10
  • 76
  • 117