Error conditions

suggest change

In browsers, blocking cookies often blocks localStorage as well, and reading it throws. This page is browser-only. querySelector returns null when no video exists, and reading volume from null also throws, so the catch is not only a storage failure. getItem returns a string or null.

const video = document.querySelector('video');
try {
    const saved = localStorage.getItem('volume');
    if (video && saved !== null) {
        video.volume = Number(saved);
    }
} catch (error) {
    alert('Volume was not restored. Storage may be blocked.');
}
if (video) {
    video.play();
}

See Error handling. An uncaught exception stops the rest of the script.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents