-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#733: adding UA sniff for history support
- Loading branch information
Showing
1 changed file
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,29 @@ | ||
|
||
// Test for the history API | ||
// http://dev.w3.org/html5/spec/history.html#the-history-interface | ||
// by Hay Kranen < http://github.com/hay > | ||
|
||
Modernizr.addTest('history', !!(window.history && history.pushState)); | ||
Modernizr.addTest('history', function() { | ||
// Issue #733 | ||
// The stock browser on Android < 3.0 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; | ||
var properCheck = !!(window.history && history.pushState); | ||
|
||
if (ua.indexOf("Android") === -1) { | ||
// No Android, simply return the 'proper' check | ||
return properCheck; | ||
} else { | ||
// We need to check for the stock browser (which identifies itself | ||
// as 'Mobile Safari'), however, Chrome on Android gives the same | ||
// identifier (and does support history properly), so check for that too | ||
if (ua.indexOf("Mobile Safari") !== -1 && ua.indexOf("Chrome") === -1) { | ||
// Buggy implementation, always return false | ||
return false; | ||
} else { | ||
// Chrome, return the proper check | ||
return properCheck; | ||
} | ||
} | ||
}); |