freecoding.school100% FREE · NO SIGNUP
Await StationISSUE #24 of 26

navigator · ua · clipboard · share

PromissaVSRace Condition Rex
Promissa saysThe navigator object exposes device/browser info and APIs like clipboard and share.

navigator holds info (language, onLine, userAgent — avoid UA sniffing) and modern APIs: navigator.clipboard.writeText, navigator.share (native share sheet on mobile), navigator.geolocation, navigator.mediaDevices. Feature-detect before using, since support and permissions vary.

Power-ups you unlock

Race Condition Rex attacks — common mistakes

Boss battleFeature-detect navigator.share and call it inside a click handler.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><button id="b">share</button><pre id="o"></pre>
<script>document.getElementById('b').onclick=async()=>{const o=document.getElementById('o');if(navigator.share){try{await navigator.share({title:'7slf',url:location.href});o.textContent='shared';}catch(e){o.textContent='cancelled';}}else o.textContent='share not supported here';};</script></body></html>
▶ Open the interactive comic issue
‹ Location · Hash · Search · HostnameWindow · InnerWidth · ScrollY · Open ›