How do you change page content and URL without reloading the whole page?
11th February 2012
My answer to How do you change page content and URL without reloading the whole page? on Quora
This can only be done using JavaScript. You use XMLHttpRequest to pull in new information from the server (also known as Ajax—most people use a JavaScript library such as jQuery to handle this) and then use the HTML5 history API, in particular the pushState method, to update the URL.
Sadly pushState isn’t supported by IE versions older than IE10—it’s up to you if you resort to fragment identifier URL hacks to support that browser or (my preferred approach) just leave IE users with full page refreshes. Sadly most versions of the Android browser don’t support pushState either, and performance constraints on mobile means they are harder to ignore than IE.
More recent articles
- My AI/LLM predictions for the next 1, 3 and 6 years, for Oxide and Friends - 10th January 2025
- Weeknotes: Starting 2025 a little slow - 4th January 2025
- I still don't think companies serve you ads based on spying through your microphone - 2nd January 2025