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
- Qwen2.5-Coder-32B is an LLM that can code well that runs on my Mac - 12th November 2024
- Visualizing local election results with Datasette, Observable and MapLibre GL - 9th November 2024
- Project: VERDAD - tracking misinformation in radio broadcasts using Gemini 1.5 - 7th November 2024