MENU
Handling Browser Events
Network Network Network online, offline
RESETRUNFULL
window.addEventListener('offline', (event) => {
console.log("The network connection has been lost.");});
Session History Session History Session History pagehide, pageshow, popstate
RESETRUNFULL
<!DOCTYPE html><html><body><script>const eventLogger = event => {
switch (event.type) {
case "pagehide":
case "pageshow":
let isPersisted = event.persisted ? "persisted"
: "not persisted";
console.log('Event:', event.type, '-', isPersisted);
break;
default:
console.log('Event:', event.type);
break;
}};["pagehide","pageshow","unload","load"].forEach(
eventName =>
window.addEventListener(eventName, eventLogger));</script></body></html>
Printing Printing Printing beforeprint, afterprint
View View View fullscreenchange, fullscreenerror, resize, scroll
Clipboard Clipboard Clipboard cut, copy, paste
RESETRUNFULL
<!DOCTYPE html><html><body>
<input type="text" value="Copy Cat">
<button onclick="myFunction()">
Copy text</button><br/><br/>
<input type="text" placeholder="Try pasting it here"/>
<script>
function myFunction() {
var copyText = document.querySelector(
"input:first-of-type");
copyText.select();
copyText.setSelectionRange(0, 99999)
document.execCommand("copy");
alert("Copied the text: " + copyText.value);
}
document.querySelector("input:last-of-type").
addEventListener('paste', function(event){
let paste = (event.clipboardData ||
window.clipboardData).getData('text');
event.preventDefault();
this.value=paste.toUpperCase();
});
</script></body></html>
Progress Progress Progress abort, error, load, loadend, loadstart, progress, timeout
RESETRUNFULL
const xhr = new XMLHttpRequest();xhr.onloadend=function(event){alert(JSON.stringify(event))};xhr.open("GET", "html.html");xhr.send();
Window Window Window close