子視窗若使用者忘記關閉,會佔用系統資源。本教學示範建立「15 秒自動關閉」且提供「手動關閉連結」的子視窗頁面,以及主頁面開啟子視窗的連結設定。

Sample 資料夾,新增 (子視窗)與 firstpage.html(主頁)。,選單「檢視 → Head 內容」顯示文件頭部區域。
setTimeout("self.close()", 15000)###(空連結)。> 前加入:onclick="self.close()"
。firstpage.html,輸入「點擊這裡開啟會自動關閉的子視窗」。###。> 前加入:onclick="window.open('index.html', null, 'width=200px,height=200px')"
結合 setTimeout 自動關閉與 onclick=self.close() 手動關閉,提供雙重保障。主頁面用 window.open 控制子視窗尺寸,無需行為面板即可快速實現。