Last Update: 11/7/2016

HostNavigationService

This API is in private preview and subject to change.

Service which allows interaction with the browser location and navigation of the host frame

Example

    // Get navigation service
    VSS.getService(VSS.ServiceIds.Navigation).then(function(navigationService) {
        // Get current hash value from host url
        navigationService.getHash().then(function (hash) {
            console.log("Host hash value: " + hash);                        
        });
    });

See Host navigation for additional samples.

Methods

updateHistoryEntry()

Update the current history entry

Syntax

 void updateHistoryEntry(action, data, replaceHistoryEntry, mergeWithCurrentState, windowTitle, suppressNavigate)

Parameters

  • action: string. The "action" state parameter. This is the _a key in the url or "action" in the current state dictionary
  • data: IDictionaryStringTo<any>. Optional. The history entry's new state key/value pairs
  • replaceHistoryEntry: boolean. Optional. If true, replace the current history entry. Otherwise, add a new history entry.
  • mergeWithCurrentState: boolean. Optional. If true, the supplied data just modify the existing/current state. If false, they replace all existing key/value pairs.
  • windowTitle: string. Optional. The new window title. A null or empty value indicates to leave the title unchanged.
  • suppressNavigate: boolean. Optional. If true, don't trigger any of the attached navigate event handlers due to this update.

getCurrentState()

Get the current navigation state dictionary. Uses query parameters and hash parameters.

Syntax

 any getCurrentState()

Parameters

Returns

  • any

attachNavigate()

Attach a new navigate handler

Syntax

 void attachNavigate(action, handler, checkCurrentState)

Parameters

  • action: string. The action that the handler applies to (or null to listen for all events)
  • handler: IFunctionPPR<any, any, void>. The method called whenever a navigation event occurs with the matching action value
  • checkCurrentState: boolean. Optional. If true, immediately invoke the handler if the current state is appropriate (has the matching action value)

detachNavigate()

Remove a navigate handler

Syntax

 void detachNavigate(action, handler)

Parameters

  • action: string. The action that the handler applies to (or null for global handlers)
  • handler: IFunctionPPR<any, any, void>. Optional. The method called whenever a navigation event occurs with the matching action value

onHashChanged()

Add a callback to be invoked each time the hash navigation has changed

Syntax

 void onHashChanged(callback)

Parameters

  • callback: (hash: string): void. Method invoked on each navigation hash change

getHash()

Gets the current hash.

Syntax

 Q.Promise<string> getHash()

Parameters

Returns

  • Q.Promise<string>

reload()

Reloads the parent frame

Syntax

 void reload()

Parameters

setHash()

Sets the provided hash from the hosted content.

Syntax

 void setHash(hash)

Parameters

  • hash: string.

replaceHash()

Replace existing hash with the provided hash from the hosted content.

Syntax

 void replaceHash(hash)

Parameters

  • hash: string.

setWindowTitle()

Update the host document's title (appears as the browser tab title).

Syntax

 void setWindowTitle(title)

Parameters

  • title: string. The new title of the window