有没有办法激活控制 WebView 桌面模式而不是移动模式? [英] there is a way to activate a control WebView Desktop mode and not Mobile mode?

查看:30
本文介绍了有没有办法激活控制 WebView 桌面模式而不是移动模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法激活控件 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.com"));
httpRequestMessage.Headers.Append("User-Agent",userAgent);

myWebView.NavigateWithHttpRequestMessage(httpRequestMessage);

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆