windows phone 8-返回按钮返回到WebBrowser WP8 youtube网站



我制作了一个WebBrowser,除了youtube网站中的后退按钮外,它还能工作。Youtube有一个重定向到移动版本,这会导致循环

该代码不适用于

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
  webBrowser.InvokeScript("eval", "history.go(-1)" );
}

我知道在这个事件中是否是重定向(302)?

webBrowser_Navigated(对象发送方,NavigationEventArgs e)

在WebBrowserControl文档中,您可以找到所有可用的方法和事件。它不是很漂亮,但你应该试试:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{        
    webBrowser.GoBack();
    e.Cancel = true;
}
void webBrowser_Navigating(object sender, NavigatingEventArgs e)
{
    if (e.Uri.ToString().Contains("YouTubeUriYouGetAlwaysRedirectedTo"))
    {
        // Do some stuff here
        e.Cancel = true;
    }
}

最新更新