Skip to content

Instantly share code, notes, and snippets.

@zacechola
Created June 5, 2015 14:34
Show Gist options
  • Save zacechola/20a98296ece858fbcf0e to your computer and use it in GitHub Desktop.
Save zacechola/20a98296ece858fbcf0e to your computer and use it in GitHub Desktop.
Polyfill history.js using Modernizr
Modernizr.addTest('history', function() {
var ua = navigator.userAgent;
if ((ua.indexOf('Android 2.') !== -1 ||
(ua.indexOf('Android 4.0') !== -1)) &&
ua.indexOf('Mobile Safari') !== -1 &&
ua.indexOf('Chrome') === -1 &&
ua.indexOf('Windows Phone') === -1) {
return false;
}
// Return the regular check
return (window.history && 'pushState' in window.history);
});
if (!Modernizr.history) {
yepnope('/path/to/history.js');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment