admin管理员组文章数量:1313091
I am running a webapp that is displayed just after a user successfully logged on a wifi network using a captive portal.
On iOS, after the user logs in, my webapp is displayed in the CNA (Captive Network Assistant) popup and the top right button label is turned to "Ok" to allow the user to close this popup.
I want to have a specific behavior in my webapp when it is displayed inside this CNA popup, so I am trying to detect (with Javascript) if my webapp is displayed in such a popup.
I first bet on the window.innerHeight value but on my iPhone 5 it seems difficult :
- 460px height inside Safari
- 440px height inside Safari during shared connection or telephone call
- 459px height inside Captive Network Assistant
- 439px height inside Captive Network Assistant during shared connection or telephone call
1px difference is, in my point of view, not enough to figure out if I am in this CNA popup.
Is there any other javascript information I can rely on to determine if I am in such a popup ?
Thank you
I am running a webapp that is displayed just after a user successfully logged on a wifi network using a captive portal.
On iOS, after the user logs in, my webapp is displayed in the CNA (Captive Network Assistant) popup and the top right button label is turned to "Ok" to allow the user to close this popup.
I want to have a specific behavior in my webapp when it is displayed inside this CNA popup, so I am trying to detect (with Javascript) if my webapp is displayed in such a popup.
I first bet on the window.innerHeight value but on my iPhone 5 it seems difficult :
- 460px height inside Safari
- 440px height inside Safari during shared connection or telephone call
- 459px height inside Captive Network Assistant
- 439px height inside Captive Network Assistant during shared connection or telephone call
1px difference is, in my point of view, not enough to figure out if I am in this CNA popup.
Is there any other javascript information I can rely on to determine if I am in such a popup ?
Thank you
Share Improve this question asked Nov 14, 2013 at 15:00 Lionel TressensLionel Tressens 4815 silver badges13 bronze badges1 Answer
Reset to default 8Well finally I detect the CNA with the user agent. When inside the CNA the user agent does not include "Safari/" in the UA string. Also tested with a dozen of alternative browsers like Opera mini, Dolphin, Mercury, Puffin, Atomic, 360 Lite, ...
For example Safari UA string is :
Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25
On the same device, inside a CNA, the user agent string would be :
Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d
So in PHP my detection looks like :
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
if ((strpos($userAgent, 'iphone') || strpos($userAgent, 'ipad')) &&
(strpos($userAgent, 'mozilla/') !== false) &&
(strpos($userAgent, 'applewebkit/') !== false) &&
(strpos($userAgent, 'mobile/') !== false) &&
(strpos($userAgent, 'safari') === false))
{
// Yes, we are in a CNA popup
[...]
}
本文标签: Javascript detection of iOS Captive Network Assistant webpageStack Overflow
版权声明:本文标题:Javascript detection of iOS Captive Network Assistant webpage - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741948862a2406588.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论