Event 1059 - Ajax Navigation
- Logged Message
- What Is It?
- When Is This Event Logged?
- Related topics
What Is It?
A page can update the hash of the URL by changing the window.location.hash property. Doing so adds an entry to the travelog of the current page. The effect is that when you click the Back button you'll navigate to the last value of window.location.hash rather than the last page you visited. Consider a simple example:
Assume you have a mapping site that uses AJAX controls. The user navigates to the site which adds an entry to the travel log. The user then performs the following functions:
A. Enters a street address and clicks a button to display the corresponding map.
B. Places a push pin at a location on the map.
C. Zooms in.
The developer has written the site so that each of these actions results in updating the window.location.hash property. Each time this happens, Internet Explorer 8 updates the travel log. The end result is that when the user clicks the back button three times, this is what happens (in order):
- The user is returned to [B] – the push pin exists but the map is no longer zoomed in.
- The user is returned to [A] – the map of the entered address is displayed but without the push pin.
- The user is returned to the initial page for the mapping site.
Each time you set the window.location.hash property two important things happen:
- The previous URL, which may contain a previous hash fragment is added to the travel log (so clicking the back button returns to that URL).
- A onhashchange event is raised.
This behavior works well for new AJAX-enabled websites. The potential problem is that some websites manually manipulate the hash of the URL for their own purposes. So introducing code that explicitly sets window.location.hash (and modifies the URL) might break those webpages.
When Is This Event Logged?
Perform the following steps to see this event logged in the Internet Explorer Compatibility Test Tool:
Create a webpage with the following contents. For this example call it 1059.html.
Install the file in the root directory of the local web server. On an Microsoft Internet Information Server (IIS) server this means putting the file in this directory:
Browse to the file:
Click the zoom-in control (the magnifying glass in the upper left with the plus (+) sign). The URL changes after the #.
Click the Back button in the browser.
You're returned to the previous zoom setting. And notice that the hash fragment in the URL is restored to the value before you zoomed into the map.
The behavior described for this event only occurs if the page is being rendered using IE8 mode. So putting the page into IE7 Standards mode is a workaround. In this case, setting window.location.hash will not affect the travelog.