5 if (window
.localStorage
.stage
== 'one') {
6 console
.log('1. Got to page 2. Going to #foo.');
7 window
.localStorage
.stage
= 'two';
8 // Navigate in a timeout to make sure we create a history entry.
9 setTimeout(function() {
10 window
.location
.href
= '#foo';
12 } else if (window
.localStorage
.stage
== 'five') {
13 console
.log('5. Got to page 2 onload. Success.');
14 window
.localStorage
.stage
= 'six';
19 onhashchange = function()
21 if (window
.localStorage
.stage
== 'two') {
22 console
.log('2. Got to page 2 #foo. Going back to start.');
23 window
.localStorage
.stage
= 'three';
28 // Go forward to fragment after the page is finished parsing.
29 document
.addEventListener('DOMContentLoaded', function() {
30 if (window
.localStorage
.stage
== 'four') {
31 console
.log('4. Got back to page 2. Immediately going forward.');
32 window
.localStorage
.stage
= 'five';
38 <!-- Slow image to let us to go forward while the page is still loading. -->
39 <img src=
"slow-resource.pl?delay=100"></iframe>