Lesson 7 of 9
Clipboard & Fullscreen APIs
Modern browser APIs provide programmatic access to the clipboard (copy/paste) and fullscreen mode. The Clipboard API replaces the deprecated document.execCommand('copy') with a clean promise-based interface. The Fullscreen API lets any element (not just the page) go fullscreen - perfect for videos, games, and presentations.
Clipboard & Fullscreen
- navigator.clipboard.writeText('text') - Copies text to clipboard. Returns a Promise. Requires HTTPS.
- navigator.clipboard.readText() - Reads clipboard content. Requires explicit user permission.
- element.requestFullscreen() - Makes any element fullscreen. Works on <video>, <canvas>, <div>, etc.
- document.exitFullscreen() - Exits fullscreen mode.
- document.fullscreenElement - Returns the element currently in fullscreen, or null.
- :fullscreen CSS pseudo-class - Style elements differently when in fullscreen mode.
- Copy button pattern: <button onclick="navigator.clipboard.writeText(code.textContent)">๐ Copy</button>
Diagram
Loading diagramโฆ
Modern browser APIs provide native copy-paste and full-screen presentation modes
Key Takeaways
- Modern browser APIs provide programmatic access to the clipboard (copy/paste) and fullscreen mode.
- navigator.clipboard.writeText('text') - Copies text to clipboard. Returns a Promise. Requires HTTPS.
- navigator.clipboard.readText() - Reads clipboard content. Requires explicit user permission.
- element.requestFullscreen() - Makes any element fullscreen. Works on <video>, <canvas>, <div>, etc.
Finished this lesson?
0 of 9 in Module 8