[英]how to detect website open in webview or browser using javascript
I want the JavaScript code for checking whether a website is open in webview (in application webview) or mobile Browser (like google chrome, uc browser). 我想要用于检查网站是否在webview(在应用程序webview中)或移动浏览器(例如google chrome,uc浏览器)中打开的JavaScript代码。
I referred to these links: But it's not working for me .. 我指的是这些链接:但这对我不起作用..
Detect inside Android Browser or WebView 在Android浏览器或WebView中检测
Activity -> onCreate 活动-> onCreate
this.webView.getSettings().setUserAgentString(
this.webView.getSettings().getUserAgentString()
+ " "
+ getString(R.string.user_agent_suffix)
);
Res -> Values -> strings.xml RES->值-> strings.xml
<string name="user_agent_suffix">AppName/1.0</string>
Javascript Java脚本
function() isNativeApp {
return /AppName\/[0-9\.]+$/.test(navigator.userAgent);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.