我需要办理停止功能,用于浏览器一些建议页。 它必须是由buttonclick引起的,所以我想我需要javascript来解决这个问题。 有人已经遇到过这个问题吗?WP7 web浏览器 - 停止渲染
迎接 roqstr
我需要办理停止功能,用于浏览器一些建议页。 它必须是由buttonclick引起的,所以我想我需要javascript来解决这个问题。 有人已经遇到过这个问题吗?WP7 web浏览器 - 停止渲染
迎接 roqstr
什么工作的罚款:
private void cancel_Click(object sender, MouseButtonEventArgs e)
{
browser.InvokeScript("eval", "document.execCommand('Stop');");
}
感谢你的努力。
public MainPage()
{
InitializeComponent();
//wb is the webbrowser
wb.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(wb_LoadCompleted);
//pretty sure you need this somewhere other than the constructor, or you'll get that
//"cannot navigate until in visual tree" exception
wb.NavigateToString(MyHTMLString);
}
void wb_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
wb.Navigating += new EventHandler<NavigatingEventArgs>(wb_Navigating);
}
void wb_Navigating(object sender, NavigatingEventArgs e)
{
e.Cancel = true;
}
的想法基本上是。覆盖LoadCompleted
,并且要加载加载页面后,确保没有其他页面可以通过设置e.Cancel
的Navigating
事件中被导航到。
你说的“停止”的意思究竟是什么? – 2012-02-11 15:01:36
如果您尝试在浏览器内停止导航,则只需在您想要的初始页面具有LoadCompleted之后覆盖导航,然后使用e.Cancel NavigationArgs。 – 2012-02-11 16:38:03
@willmel:是否可以访问活动的“导航”方法,设置e.cancel = true? – roqstr 2012-02-11 17:51:26