file_online_offline_bfcache.html (1145B)
1 <html> 2 <head> 3 <script> 4 onpageshow = function(pageshowEvent) { 5 let bc = new BroadcastChannel("online_offline_bfcache"); 6 bc.onmessage = function(event) { 7 if (event.data == "nextpage") { 8 bc.close(); 9 location.href = location.href + "?nextpage"; 10 } else if (event.data == "back") { 11 bc.close(); 12 history.back(); 13 } else if (event.data == "forward") { 14 bc.close(); 15 history.forward(); 16 } else if (event.data == "close") { 17 bc.postMessage("closed"); 18 bc.close(); 19 window.close(); 20 } 21 }; 22 bc.postMessage({ event: pageshowEvent.type, persisted: pageshowEvent.persisted }); 23 } 24 25 onoffline = function(event) { 26 let bc = new BroadcastChannel("online_offline_bfcache"); 27 bc.postMessage(event.type); 28 bc.close(); 29 } 30 31 ononline = function(event) { 32 let bc = new BroadcastChannel("online_offline_bfcache"); 33 bc.postMessage(event.type); 34 bc.close(); 35 } 36 37 </script> 38 </head> 39 <body> 40 </body> 41 </html>