我需要辦理停止功能,用於瀏覽器一些建議頁。 它必須是由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