Inhaltsverzeichnis reduzieren
Inhaltsverzeichnis erweitern
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

hashchange | onhashchange event

This event is not supported for Windows Store apps using JavaScript.


HTML Attribute <element onhashchange = "handler(event)">
Event Property object.onhashchange = handler;
addEventListener Method object.addEventListener("hashchange", handler, useCapture)


Event information



Event handler parameters

pEvtObj [in]

Type: IHTMLEventObj

Standards information

There are no standards that apply here.


In Asynchronous JavaScript and XML (AJAX) applications, client requests that do not trigger traditional page navigation should update the hash property. This lets the Back button function more predictably. The URL fragment (bookmark) can be set by script. The value is appended to the displayed URL, and the navigation is saved in the browser history.

When first navigating to a page that contains a hash identifier in the URL, an onhashchange event is not fired. It is expected that the freshly loaded page can inspect the value of the location.hash property to extract the current hash value. After this first page loads, setting the hash property will fire the onhashchange event as expected. This behavior avoids any negative impact on Web page load performance by removing a possible redundant event.

To invoke this event, do one of the following:

  • Set the location.hash (bookmark) property.
  • Navigate to the same page with a different bookmark.


Attaching an event handler to a new onhashchange event enables the page to detect when the hash has changed and an AJAX navigation has occurred. See Introducing AJAX Navigations for a more robust example.

<body onhashchange="HashChangeHandler();">

See also

Introducing AJAX Navigations



© 2017 Microsoft