Raised when there are changes to the portion of a URL that follows the number sign (#).
void onhashchange( IHTMLEventObj *pEvtObj );
No return value.
The DISPID for this event is defined in mshtmdid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
Bubbles Yes Cancels Yes To invoke Default action N/A
Event Object Properties
The IHTMLEventObj interface contains additional information about the current event. When the onhashchange event is fired, you can use the IHTMLWindow2::event property to retrieve an IHTMLEventObj interface. To obtain an alternate interface pointer such as IHTMLEventObj2 or IHTMLEventObj3, call QueryInterface on the object.
IHTMLEventObj::cancelBubble Sets or retrieves whether the current event should bubble up the hierarchy of event handlers. IHTMLEventObj::type Gets the event name from the event object. IHTMLEventObj2::type Gets or sets the event name from the event object.
Refer to the specific event object for additional event properties.
Windows Internet Explorer 8. The browser's Back and Forward buttons do not generate HTMLWindowEvents3::onhashchange events for frames or iframes; instead, the frame is refreshed each time. Web pages hosted in frames or iframes should use their onload handler or equivalent to read the current URL hash information from the location. hash property and set their states accordingly.
When first navigating to a page that contains a hash identifier in the URL, an HTMLWindowEvents3::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 HTMLWindowEvents3::onhashchange event as expected. This behavior avoids any negative impact on Web page load performance by removing a possible redundant event.