For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface Navigation

The Navigation interface of the Navigation API allows control over all navigation actions for the current window in one central place, including initiating navigations programmatically, examining navigation history entries, and managing navigations as they happen.

MDN Reference

interface Navigation {
    activation: NavigationActivation | null;
    canGoBack: boolean;
    canGoForward: boolean;
    currentEntry: NavigationHistoryEntry | null;
    oncurrententrychange:
        | ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any)
        | null;
    onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null;
    onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null;
    onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null;
    transition: NavigationTransition | null;
    addEventListener<K extends keyof NavigationEventMap>(
        type: K,
        listener: (this: Navigation, ev: NavigationEventMap[K]) => any,
        options?: boolean | AddEventListenerOptions,
    ): void;
    addEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | AddEventListenerOptions,
    ): void;
    back(options?: NavigationOptions): NavigationResult;
    dispatchEvent(event: Event): boolean;
    entries(): NavigationHistoryEntry[];
    forward(options?: NavigationOptions): NavigationResult;
    navigate(
        url: string | URL,
        options?: NavigationNavigateOptions,
    ): NavigationResult;
    reload(options?: NavigationReloadOptions): NavigationResult;
    removeEventListener<K extends keyof NavigationEventMap>(
        type: K,
        listener: (this: Navigation, ev: NavigationEventMap[K]) => any,
        options?: boolean | EventListenerOptions,
    ): void;
    removeEventListener(
        type: string,
        listener: EventListenerOrEventListenerObject,
        options?: boolean | EventListenerOptions,
    ): void;
    traverseTo(key: string, options?: NavigationOptions): NavigationResult;
    updateCurrentEntry(options: NavigationUpdateCurrentEntryOptions): void;
}

Hierarchy

  • EventTarget
    • Navigation
Index
activation: NavigationActivation | null

The activation read-only property of the Navigation interface returns a NavigationActivation object containing information about the most recent cross-document navigation, which "activated" this Document. The property will stay constant during same-document navigations.

MDN Reference

canGoBack: boolean

The canGoBack read-only property of the Navigation interface returns true if it is possible to navigate backwards in the navigation history (i.e., the currentEntry is not the first one in the history entry list), and false if it is not.

MDN Reference

canGoForward: boolean

The canGoForward read-only property of the Navigation interface returns true if it is possible to navigate forwards in the navigation history (i.e., the currentEntry is not the last one in the history entry list), and false if it is not.

MDN Reference

currentEntry: NavigationHistoryEntry | null

The currentEntry read-only property of the Navigation interface returns a NavigationHistoryEntry object representing the location the user is currently navigated to right now.

MDN Reference

oncurrententrychange:
    | ((this: Navigation, ev: NavigationCurrentEntryChangeEvent) => any)
    | null
onnavigate: ((this: Navigation, ev: NavigateEvent) => any) | null
onnavigateerror: ((this: Navigation, ev: ErrorEvent) => any) | null
onnavigatesuccess: ((this: Navigation, ev: Event) => any) | null
transition: NavigationTransition | null

The transition read-only property of the Navigation interface returns a NavigationTransition object representing the status of an in-progress navigation, which can be used to track it.

MDN Reference

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Type Parameters

    Parameters

    Returns void

  • The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

    MDN Reference

    Parameters

    Returns void

  • The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

    MDN Reference

    Type Parameters

    Parameters

    Returns void

  • The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

    MDN Reference

    Parameters

    Returns void

Was this helpful?