Skip to content

Instantly share code, notes, and snippets.

@richgcook
Created February 20, 2014 00:48
Show Gist options
  • Save richgcook/9104746 to your computer and use it in GitHub Desktop.
Save richgcook/9104746 to your computer and use it in GitHub Desktop.
history.replaceState (URL); useful when using AJAX
var pushSupport = $('html').hasClass('history') ? true : false; // does html have class .history? (modernizr.js required)
var toLoad = $('.element').attr('href'); // toLoad variable is .element's href attribute
if (pushSupport === true) { // if html does have class .history
history.replaceState(null, null, toLoad); // replace URL with the new href
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment