file_scrollRestoration_bfcache_and_nobfcache.html (832B)
1 <html> 2 <head> 3 <script> 4 // Ensure layout is flushed before doing anything with scrolling. 5 function flushAndExecute(callback) { 6 window.requestAnimationFrame(function() { 7 setTimeout(callback); 8 }); 9 } 10 11 var bc = new BroadcastChannel("bfcached"); 12 bc.onmessage = (msgEvent) => { 13 if (msgEvent.data == "loadNext") { 14 flushAndExecute(() => { 15 location.href = "file_scrollRestoration_bfcache_and_nobfcache_part2.html"; 16 }); 17 } else if (msgEvent.data == "forward") { 18 flushAndExecute(() => { 19 history.forward(); 20 }); 21 } 22 }; 23 window.onpageshow = (event) => { 24 bc.postMessage({command: "pageshow", persisted: event.persisted}); 25 }; 26 </script> 27 </head> 28 <body> 29 </body> 30 </html>