【问题标题】:Windows Phone Webview change userAgentWindows Phone Webview 更改 userAgent
【发布时间】:2016-03-09 03:24:14
【问题描述】:

如何永久更改 Windows Phone Webview 的用户代理?

 protected override void OnNavigatedTo(NavigationEventArgs e)
    {

        string ua = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.20 Mobile Safari/537.36";
        HttpRequestMessage hrm = new HttpRequestMessage(HttpMethod.Get, homeUri);
        hrm.Headers.Add("User-Agent", ua);
        webView.NavigateWithHttpRequestMessage(hrm);
    }

它在网页加载之前一直有效,但如果我在 webview 中打开一个子页面,它会使用标准用户代理。

非常感谢。

【问题讨论】:

    标签: c# webview windows-phone


    【解决方案1】:

    看这里:Changing the user agent of the WebBrowser control

    另一种可能的解决方案是拦截点击事件并更改 HttpRequest 消息,请参见此处:How can I detect when the user clicks on a hyperlink in a WebView control?

    让我知道它是否有效!

    【讨论】:

    • Webbrowser 不是一个选项,因为我使用的是 webview,但点击拦截有效。非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多