Share via


WinJS.Navigation Namespace

Provides functionality for managing navigation, including the navigation stack.

The Microsoft Visual Studio project templates for Windows apps using JavaScript (Hub, Grid, Split, and Navigation) use the single-page navigation model. In this model, HTML pages are loaded via the page's URI into a single, app-wide context. The pages are loaded as needed, typically in response to user actions. See JavaScript project templates for Windows Store apps to get an overview of the templates.

For help choosing the best navigation pattern for your app, see Navigation patterns.

See the Flat navigation and Hierarchical navigation patterns in action as part of our App features, start to finish series.

The WinJS.Navigation namespace has these types of members:

  • Properties
  • Functions
  • Events

Properties

Property Description

canGoBack property

Identifies whether it is possible to traverse backward through the navigation stack.

canGoForward property

Identifies whether it is possible to traverse forward through the navigation stack.

history property

Gets or sets the navigation stack.

location property

Gets a URI for an app page.

state property

Gets or sets one or more user-defined key-value pairs that can be passed between pages.

 

Functions

Function Description

addEventListener function

Adds an event listener to the control.

back function

Traverses backward in the navigation stack.

forward function

Traverses forward in the navigation stack.

navigate function

Navigates to a location with optional state values.

removeEventListener function

Removes an event listener from the control.

 

Events

Event Description

onbeforenavigate event

A page navigation event that occurs before onnavigating and onnavigated.

onnavigated event

A page navigation event that occurs after onbeforenavigate and onnavigating.

onnavigating event

A page navigation event that occurs after onbeforenavigate and before onnavigated.

 

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.Navigation

See also

For developers

Your first app - Part 3: PageControl objects and navigation

Navigating between pages

Adding app bars

Quickstart: Using single-page navigation

Quickstart: Adding a nav bar (NavBar)

Quickstart: Using a hub control for layout and navigation

WinJS.UI.Hub object

WinJS.UI.AppBar object

WinJS.UI.NavBar object

WinJS.UI.BackButton object

HTML Hub control sample

HTML AppBar control sample

HTML NavBar control sample

Navigation and navigation history sample

For designers

Navigation patterns

Command patterns

Layout

Hub

Bottom app bar

Top app bar

Back button

Guidelines for the hub control

Guidelines for app bars

Making the app bar accessible