Skip to content

Instantly share code, notes, and snippets.

@steffanwilliams
Created October 20, 2010 10:49
Show Gist options
  • Save steffanwilliams/636181 to your computer and use it in GitHub Desktop.
Save steffanwilliams/636181 to your computer and use it in GitHub Desktop.
TypeKit for iOS 4+
var ua = navigator.userAgent;
var m = RegExp(/OS\s([\d+_?]*)\slike/i).exec(ua);
var version = m != null ? m[1].replace(/_/g, '.') : 4;
if (!(ua.match(RegExp('/ip(hone|ad|od)/i'))) || (ua.match(RegExp('/ip(hone|ad|od)/i')) && version >= 4)) {
try{Typekit.load();}catch(e){}
}
<?php
// Browsing sniffing for iOS devices less than 4, as they cannot support multiple font weights.
$agent = $_SERVER['HTTP_USER_AGENT'];
$version = preg_match('/OS\s([\d+_?]*)\slike/i', $agent, $matches);
$version = str_replace('_', '.', $matches[1]);
if (!(preg_match('/ip(hone|ad|od)/i', $agent)) || ((preg_match('/ip(hone|ad|od)/i', $agent) && $version >= 4))) {
echo '<script src="http://use.typekit.com/#TYPEKIT_CODE.js"></script>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment