WebView.NavigationStarting 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
// Register
event_token NavigationStarting(TypedEventHandler<WebView, WebViewNavigationStartingEventArgs const&> const& handler) const;
// Revoke with event_token
void NavigationStarting(event_token const* cookie) const;
// Revoke with event_revoker
WebView::NavigationStarting_revoker NavigationStarting(auto_revoke_t, TypedEventHandler<WebView, WebViewNavigationStartingEventArgs const&> const& handler) const;
public event TypedEventHandler<WebView,WebViewNavigationStartingEventArgs> NavigationStarting;
function onNavigationStarting(eventArgs) { /* Your code */ }
webView.addEventListener("navigationstarting", onNavigationStarting);
webView.removeEventListener("navigationstarting", onNavigationStarting);
- or -
webView.onnavigationstarting = onNavigationStarting;
Public Custom Event NavigationStarting As TypedEventHandler(Of WebView, WebViewNavigationStartingEventArgs)
<WebView NavigationStarting="eventhandler" />
事件類型
範例
下列程式碼範例示範如何處理此事件,以更新做為網址列的文字方塊。 如需完整的範例,請參閱 XAML WebView 控制項範例。
void webViewA_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
{
string url = "";
try { url = args.Uri.ToString(); }
finally
{
address.Text = url;
appendLog(String.Format("Starting navigation to: \"{0}\".\n", url));
pageIsLoading = true;
}
}
備註
您可以將 WebViewNavigationStartingEventArgs.Cancel 屬性設定為 true,以取消此事件的處理常式導覽。
WebView 流覽事件會依下列順序發生:
- NavigationStarting
- ContentLoading
- DOMContentLoaded
- NavigationCompleted
類似事件會以WebView內容中的每個iframe相同順序發生: