" detect webview with Javascript and user agent on android versions"
Bootstrap 3.1.0 Snippet by muhittinbudak

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<script src="https://cdn.jsdelivr.net/npm/is-ua-webview@1.1.2/index.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Strait">
<div class="container" style="font-family: 'Strait', sans-serif;">
<div class="row">
<center><h2> detect webview with Javascript and user agent on android versions</h2></center>
</div>
<center><h1 class="well webviewvarsa" style="background-color:yellow">Not Android Webview Browser.</h1></center>
<span id="merak"></span>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$(document).ready(function(){
function isFacebook() {
var fresult = true;
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
const isFacebookBrowser = userAgent.includes("FBAN") || userAgent.includes("FBAV");
if (isFacebookBrowser) {
fresult = true;
} else {
fresult = false;
}
return fresult;
}
//------------
function isWebview() {
const navigator = window.navigator
const userAgent = navigator.userAgent
const normalizedUserAgent = userAgent.toLowerCase()
const standalone = navigator.standalone
const isIos =
/ip(ad|hone|od)/.test(normalizedUserAgent) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)
const isAndroid = /android/.test(normalizedUserAgent)
const isSafari = /safari/.test(normalizedUserAgent)
const isWebview = (isAndroid && /; wv\)/.test(normalizedUserAgent)) || (isIos && !standalone && !isSafari)
return isWebview
}
if(isWebview()){
$('.webviewvarsa').text("webview").css("background-color", "yellow");//
} else {
$('.webviewvarsa').text(" Not webview").css("background-color", "blue").css("color", "white");
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: