如何检测用户是否正在使用webview for android或iOS浏览页面?
有各种贴遍计算器的解决方案,但我们没有一个防弹解决方案还为两个操作系统.
目标是if语句,例如:
if (android_webview) {
jQuery().text('Welcome webview android user');
} else if (ios_webview) {
jQuery().text('Welcome webview iOS user');
} else if (ios_without_webview) {
// iOS user who's running safari, chrome, firefox etc
jQuery().text('install our iOS app!');
} else if (android_without_webview) {
// android user who's running safari, chrome, firefox etc
jQuery().text('install our android app!');
}
Run Code Online (Sandbox Code Playgroud)
检测iOS webview(来源):
if (navigator.platform.substr(0,2) === 'iP'){
// iOS (iPhone, iPod, iPad)
ios_without_webview …Run Code Online (Sandbox Code Playgroud)