【问题标题】:Use WebBrowser and OnNavigatedFrom back history WP8使用 WebBrowser 和 OnNavigatedFrom 回溯历史 WP8
【发布时间】:2014-02-17 10:21:22
【问题描述】:

我的项目 Windows phone 8 中有一个网络浏览器。 我想让浏览器类型为 Internet Explorer。 我的问题出在后退按钮上。

我在 OnNavigatedFrom 中插入以下代码: WebBrowser.InvokeScript("eval", "history.go(-1)");

但关闭 xaml 页面

在 OnNavigatedFrom e.cancel=true 中不存在?

【问题讨论】:

    标签: windows-phone-8


    【解决方案1】:

    您正在寻找覆盖 OnBackKeyPressed - 当按下返回键时,而不是 OnNavigatedFrom - 当您离开 Page 时触发:

    protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
      // you should check for example if there is history 
      if (history exists)
      {
        WebBrowser.InvokeScript("eval", "history.go(-1)");
        e.Cancel = true;
      }
      // else normal navigation - exit page - to fulfill certification requirements 
    }
    

    这是您可以覆盖的按钮之一,但请注意,要适合 Certification requirements - 5.2.4,您需要正确处理它。它必须提供导航和退出应用程序。

    【讨论】:

      猜你喜欢
      • 2014-01-05
      • 2018-07-02
      • 2014-05-03
      • 1970-01-01
      • 2016-09-01
      • 2020-03-25
      • 2012-01-17
      • 1970-01-01
      • 2010-12-28
      相关资源
      最近更新 更多