Simon Willison’s Weblog

How do you change page content and URL without reloading the whole page?

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.

This is How do you change page content and URL without reloading the whole page? by Simon Willison, posted on 11th February 2012.

Tagged , , , ,

Next: What is an intuitive explanation of Unicode and why a programmer needs to know it?

Previous: Should I take the time to learn programming, or take my idea and run with it?