<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>監控窗口是否活動</title> </head> <body> <script> window.addEventListener('blur', ()=>{ document.title = '放入后台'; }, true); window.addEventListener('focus', ()=>{ document.title = '進入頁面'; }, true); </script> </body> </html>