查明 Android 浏览器是在应用程序中运行还是自行运行

发布于 2024-12-28 11:47:57 字数 299 浏览 2 评论 0原文

我正在使用 的混合 Android 应用程序间歇泉。 我想告知用户,如果他进入我网站的移动版本,就可以下载此应用程序。问题是,应用程序中运行的浏览器可以查看与移动网站几乎相同的内容。

如果我在应用程序浏览器中运行而不是在普通浏览器中运行,如何使用 JS 进行检测? 我不想在应用程序中显示该应用程序的下载链接。

谢谢

I am using an hybrid android app from geyser.
I want to inform the user about the possibility to download this app, if he enters the mobile version of my website. the thing is, in the app runs a browser which views almost the same content as the mobile website.

how can I detect with JS if I am running in the App-Browser and not on the normal Browser?
I don't want to show the download Link of the App in the App.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪恋 2025-01-04 11:47:57

你可以做的是在你的页面上有一个 javascript 函数

setAndroidApp=function(){
    isAndroidApp=true;
}

,然后,当你通过 android 版本加载你的网站时(假设你使用的是 Android WebView class ),您可以通过以下方式在加载页面时运行该函数,

webview.loadUrl("javascript:setAndroidApp()");

在这种情况下,您将拥有 isAndroidApp 设置为 true其余的代码(如果可以从 Android 应用程序中看到)。

What you could do is have a javascript function on your page like

setAndroidApp=function(){
    isAndroidApp=true;
}

and then, when you load your site through the android version (assuming you're using the Android WebView class ), you could make the function run when loading the page in the following manner

webview.loadUrl("javascript:setAndroidApp()");

in which case, you'd have isAndroidApp set to true for the rest of your code if it's seen from the android app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文