Is there a way to differ via javascript if the website runs inside the ipad safari or inside an application WebView?
|
|
This uses a combination of Demo: http://jsfiddle.net/ThinkingStiff/6qrbn/
|
|||||
|
User Agents
Detection Code
|
|||||||||||||
|
|
I think that you can just use the UPDATE Page browsed using iPhone Safari
I will try in a second with UIWebView
The difference is that the Safari one says Solution
|
|||||||||||||||||||||
|
|
Yeah:
|
|||||||||
|
|
I know this code will check if it is being accessed from an icon added to the home screen:
but I'm not sure how it would react in a UIWebView. The only other solution I could think of is getting the user agent or using |
|||||
|
|
Neoneye's solution does not work anymore (see comments) and can be simplified. On the other hand, testing only "Safari" in the UA adresses much more than the ios handheld devices. This is the test i'm using :
|
|||
|
|
|
Would suggest using Modernizr, and checking for indexeddb like this. You could cross-check that with user agent configuration (device, OS, browser, etc), but pure feature detection seems more recommended. |
|||
|
|
|
I don't think there's anything specific you can use in client-side Javascript, but if you have control over what the originating UIWebView can do, you might want to consider playing with the user agent string it generates, and testing for that in your client-side Javascript instead? A bit of a hack I know, but hey… This question may give some pointers on tweaking the user agent: |
|||||
|
|
@ Sod, Well i don’t have answer, but i am not convinced why you want to check, Since, browser engine whether its safari ( Browser ) or Application will be same its Webkit only, Yes Application can configure the Browser engine capabilities like, whether application wants to run JS or Display Image etc… I believe, you must check for certain property whether Flash supported by Browser or whether browser displays image or not, or probably may be you would like to check the screen size, |
|||
|
|