UNPKG

modernizr

Version:

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

43 lines (38 loc) 1.28 kB
/*! { "name": "History API", "property": "history", "caniuse": "history", "tags": ["history"], "authors": ["Hay Kranen", "Alexander Farkas"], "notes": [{ "name": "W3C Spec", "href": "http://www.w3.org/TR/html51/browsers.html#the-history-interface" }, { "name": "MDN documentation", "href": "https://developer.mozilla.org/en-US/docs/Web/API/window.history" }], "polyfills": ["historyjs", "html5historyapi"] } !*/ /* DOC Detects support for the History API for manipulating the browser session history. */ define(['Modernizr'], function( Modernizr ) { Modernizr.addTest('history', function() { // Issue #733 // The stock browser on Android 2.2 & 2.3 returns positive on history support // Unfortunately support is really buggy and there is no clean way to detect // these bugs, so we fall back to a user agent sniff :( var ua = navigator.userAgent; // We only want Android 2, stock browser, and not Chrome which identifies // itself as 'Mobile Safari' as well if (ua.indexOf('Android 2') !== -1 && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1) { return false; } // Return the regular check return (window.history && 'pushState' in history); }); });