2012-02-11 129 views
0

我需要办理停止功能,用于浏览器一些建议页。 它必须是由buttonclick引起的,所以我想我需要javascript来解决这个问题。 有人已经遇到过这个问题吗?WP7 web浏览器 - 停止渲染

迎接 roqstr

+0

你说的“停止”的意思究竟是什么? – 2012-02-11 15:01:36

+0

如果您尝试在浏览器内停止导航,则只需在您想要的初始页面具有LoadCompleted之后覆盖导航,然后使用e.Cancel NavigationArgs。 – 2012-02-11 16:38:03

+0

@willmel:是否可以访问活动的“导航”方法,设置e.cancel = true? – roqstr 2012-02-11 17:51:26

回答

0

什么工作的罚款:

private void cancel_Click(object sender, MouseButtonEventArgs e) 
    { 
     browser.InvokeScript("eval", "document.execCommand('Stop');"); 
    } 

感谢你的努力。

0
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.CancelNavigating事件中被导航到。

+0

我不认为这是工作,因为它不会中断所有导航流程与1个e.cancel = TRUE; 只有wb_Navigating事件将被取消,但第一个导航过程将继续。 而我不想采取选择导航后,我按下了键,我只想取消这1个活动过程。 – roqstr 2012-02-12 10:26:03

+0

示例:user1导航到bing.com, user1导航到bing-maps,但决定在导航过程中取消导航。 按下了取消键,wb在当前点停止工作,并可用于新命令。 这是想法。 – roqstr 2012-02-12 10:30:57