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
- Notes from Bing Chat—Our First Encounter With Manipulative AI - 19th November 2024
- Project: Civic Band - scraping and searching PDF meeting minutes from hundreds of municipalities - 16th November 2024
- Qwen2.5-Coder-32B is an LLM that can code well that runs on my Mac - 12th November 2024