共用方式為


WebView.NavigationStarting 事件

定義

發生于 WebView 巡覽至新內容之前。

// 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 流覽事件會依下列順序發生:

類似事件會以WebView內容中的每個iframe相同順序發生:

適用於

另請參閱