有没有办法激活控制 WebView 桌面模式而不是移动模式?

编程入门 行业动态 更新时间:2024-10-28 10:23:34
本文介绍了有没有办法激活控制 WebView 桌面模式而不是移动模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

有没有办法激活控件 WebView 桌面模式而不是移动模式?

there is a way to activate a control WebView Desktop mode and not Mobile mode?

<WebView x:name= "WebViewApp" ..../>

推荐答案

WebView 没有固有的桌面或移动模式.站点是否提供移动或桌面优化站点通常基于用户代理标头.您可以通过创建 HttpWebRequest 使用您想要的代理,然后使用 WebView 进行导航.NavigateWithHttpRequestMessage.

The WebView doesn't have an inherent desktop or mobile mode. Whether a site provides a mobile or desktop optimised site is generally based on the User Agent header. You can set this in a WebView by creating an HttpWebRequest with the agent you want and then navigating with WebView.NavigateWithHttpRequestMessage.

如果你想模仿一个特定的浏览器模式,你可以在几个网站上找到它使用的用户代理.

If you want to mimic a specific browser mode you can find the user agent it uses at several web sites.

string userAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/7.0; Touch; rv:11.0; WPDesktop) like Gecko"
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(
    HttpMethod.Post, new Uri("http://whatsmyuseragent"));
httpRequestMessage.Headers.Append("User-Agent",userAgent);

myWebView.NavigateWithHttpRequestMessage(httpRequestMessage);

这篇关于有没有办法激活控制 WebView 桌面模式而不是移动模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 13:27:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117621.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   没有办法   而不是   桌面   WebView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!