Posts
All the articles I've posted.
網頁載入時自動朗讀內容 - 使用 SpeechSynthesisUtterance
Posted on:2023/03/03 09:17:00最近有接到一個 case 是要在網頁載入後,自動朗讀內文的內容,最後使用 JS 內建的 SpeechSynthesisUtterance 來達成這個需求。順便記錄一下遇到的問題,像是換頁不會自行中斷及手機無法自動朗讀等問題。
使用 Vue 監聽 iframe 的滾動事件
Posted on:2023/02/23 15:17:00Vue專案中嵌入 iframe,需要監聽滾動事件實現需求。文章分享了使用原生 JS 監聽 iframe 滾動事件的方法,透過ref取得DOM元素,使用 contentDocument 獲取 iframe 的 DOM 元素,再透過 addEventListener 監聽 scroll 事件。判斷是否滾動到底部的機制以 iframe 的高度、滾動高度、可視高度為參考,並在 Vue 組件中實現相應邏輯。針對一些可能遇到的問題,如部分 iframe 未監聽到滾動事件、Android 取不到 iframe 的相關屬性、特定瀏覽器滾動到底部未觸發事件,提供了解決方案。加強滾動事件的穩定監聽,確保按鈕在滾動到底部時正確觸發,提升用戶體驗。
六角學院 - JavaScript工程師養成直播班
Posted on:2022/11/26 22:00:00之前在工作上常常會被問到網站是否能加快速度,網路上資源實在是五花八門,看了各篇相關資訊後,覺得吸收度實在不佳,都是針對內文的項目一筆一筆做調整,但總體而言沒有一個完整的概念以及可以提出有依據的解決結果回報。