处理硬件后退按钮,并把它发送到WebBrowser控件在Windows Phone上运行 [英] Handling hardware back button and sending it to WebBrowser control running on Windows Phone

查看:171
本文介绍了处理硬件后退按钮,并把它发送到WebBrowser控件在Windows Phone上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有嵌入PhoneApplicationPage一个Web浏览器控件。我要处理硬件后退按钮,并迫使Web浏览器回去。

I have a web browser control embedded into a PhoneApplicationPage. I have to handle the hardware back button and force the web browser to go back.

know如何处理硬件后退按钮。

I know how to handle hardware back button.

你如何强制web浏览器要到previous页?看似简单的 GoBack的() CanGoBack 的WinForms的网页浏览器属性似乎缺少在Windows Phone上。

How do you force the webbrowser to go to a previous page? The seemingly simple GoBack() and CanGoBack property on WinForms webbrowser seems to be missing on Windows Phone.

推荐答案

如果您通过设置启用的 web浏览器控制脚本 IsScriptEnabled =真则可以使用以下方法来在浏览器中向后导航:

If you enable script on the WebBrowser control by setting IsScriptEnabled="true" you can then use the following to navigate backwards within the browser:

private void backButton_Click(object sender, EventArgs e)
{
  try
  {
    browser.InvokeScript("eval", "history.go(-1)");
  }
  catch
  {
    // Eat error
  }
}

您可以找到这个code(和多一点)的肖Wildermuth的博客文章导航与WP7 WebBrowser控件。

You can find this code (and a bit more) in Shaw Wildermuth's blog post Navigating with the WebBrowser Control on WP7.

这篇关于处理硬件后退按钮,并把它发送到WebBrowser控件在Windows Phone上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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