2012-02-11 110 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