![](/img/trans.png)
[英]How to detect the url opening from web browser(chrome) or webview(mobile app) using jquery/javascript in the website?
[英]how to detect website open in webview or browser using javascript
我想要用于检查网站是否在webview(在应用程序webview中)或移动浏览器(例如google chrome,uc浏览器)中打开的JavaScript代码。
我指的是这些链接:但这对我不起作用..
在Android浏览器或WebView中检测
活动-> onCreate
this.webView.getSettings().setUserAgentString(
this.webView.getSettings().getUserAgentString()
+ " "
+ getString(R.string.user_agent_suffix)
);
RES->值-> strings.xml
<string name="user_agent_suffix">AppName/1.0</string>
Java脚本
function() isNativeApp {
return /AppName\/[0-9\.]+$/.test(navigator.userAgent);
}
从这里复制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.