I want to be able to change the address of a page but not issue any HTTP requests upon making that change. How can this be done using JavaScript?
You can set location.hash without a page load, but i'm not sure if that's what you're wanting -- your question is fairly vague.
Assuming that you mean the address indicated in the browser's address bar, I don't believe that it can. Setting document.location or window.location will automatically trigger a page reload, as far as I know.
As olliej said, you can change the hash parameter (a.k.a. fragment identifier), which does not trigger a page reload.
You mean like, I'm visiting http://www.fakebank.example
and you want the address bar to display http://www.yourbank.example
? I think there are obvious reasons this won't be possible.
Do you not want to add a history entry? Just use location.replace(..)
.
To answer your question directly: it's impossible. You're asking how can you go to a different page without going to a different page, which is nonsense.
Although if a page is already in the browser cache (and a far future date has been set) then technically the user may be able to go to that page without requesting it again from your server. But you can't guarantee anything.
I think what you may be looking for is something like using frames. On example.com/index.html
you can set up a full size frame and include a different page such as example.com/page2.html
. Then any links within the frame won't change the URL listed in the browser. See this tutorial for info.
What you're asking for is called URL spoofing.
Any browser allowing this has a severe security issue.