Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created August 20, 2015 13:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisallick/1d8875b1c23d377cc385 to your computer and use it in GitHub Desktop.
Save chrisallick/1d8875b1c23d377cc385 to your computer and use it in GitHub Desktop.
JavaScript only solution for detecting UIWebView.
// http://stackoverflow.com/questions/4460205/detect-ipad-iphone-webview-via-javascript
var standalone = window.navigator.standalone,
userAgent = window.navigator.userAgent.toLowerCase(),
safari = /safari/.test( userAgent ),
ios = /iphone|ipod|ipad/.test( userAgent );
if( ios ) {
if ( !standalone && safari ) {
//browser
} else if ( standalone && !safari ) {
//standalone
} else if ( !standalone && !safari ) {
//uiwebview
};
} else {
//not iOS
};
@svlada
Copy link

svlada commented Dec 10, 2017

This approach is not working UIWebView on IPad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment