Android webview 像原生浏览器一样工作

发布于 2024-12-27 17:26:11 字数 336 浏览 1 评论 0原文

我在 Android 中尝试 WebView,但不知道如何让它像本机浏览器一样工作。

我有一个例子: 在本机浏览器中访问 deviantART.com。按菜单按钮。菜单底部将有一个禁用移动视图的链接,它按预期工作。这完全相同的事情在 WebView 中不起作用。它只是关闭菜单,仅此而已,mobil CSS 仍然保持不变。

我需要让用户禁用 deviantART 的移动 CSS,所以我需要 WebView 像这样工作。

JavaScript 和 DOMStorage 已启用。

我需要正确的代码或解决方法,但经过几个小时的搜索,我没有找到与此问题相关的任何内容。

先感谢您。

I experimenting with WebView in Android and I can't figure out how to make it work like the native browser.

I have an example for this:
Go to deviantART.com in native browser. Press Menu button. At the bottom of the menu there will be a link to disable mobile view and it works as expected. This exact same thing doesn't work in WebView. It simply turns the menu off and that is all, mobil CSS still stays intact.

I need to make users disable deviantART's mobile CSS, so I need the WebView to work like this.

JavaScript and DOMStorage are enabled.

I need the proper code or an workaround, but after hours of searching I didn't find anything that connected to this problem.

Thank you in advance.

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

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

发布评论

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

评论(1

娜些时光,永不杰束 2025-01-03 17:26:11

如果您只想关闭移动视图,则可以使用 setUserAgentString (String ua)WebView 上设置用户代理字符串。

If all you want is to turn off the mobile view you can set the user-agent string on the WebView using setUserAgentString (String ua).

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