HTML onhashchange Attribute

❮ HTML Attributes


<body onhashchange="myFunction()">


The onhashchange attribute fires when the URL’s hash identifier value changes.

Changing this value is commonly performed in Ajax applications to indicate a state change and support browser back-button activity.

Standard Syntax

<element onhashchange="script">

Browser Support


Applies to:

The onhashchange attribute can be used on the following element:

Element Attribute
<body> onhashchange

Attribute Values

Value Description
script Specifies the script to be run on onhashchange
❮ HTML Attributes