[英]getBoundingClientRect return 0 for top, left, right, bottom in Safari
所以,我有一個由 Facebook 的draft-js
提供支持的 contenteditable div。 我需要獲得該 div 中插入符號的視覺位置,我實現了這個(在 Firefox 和 Chrome 中有效):
const selection = window.getSelection && window.getSelection();
if (selection.rangeCount > 0) {
const coordinates = selection.getRangeAt(0).getBoundingClientRect();
}
在 Chrome 和 Firefox 的情況下,我得到正確的坐標。 但是,在 Firefox 中,我的所有位置屬性都為 0。 任何解決方法/跨瀏覽器的解決方案?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.