如何同时获取选中的文本和单词的xy坐标??
最佳答案
刚刚用谷歌搜索了一下:
var txt = "";
if (window.getSelection) {
txt = window.getSelection();
} else if (document.getSelection) {
// FireFox
txt = document.getSelection();
} else if (document.selection) {
// IE 6/7
txt = document.selection.createRange().text;
}
txt = txt.toString()
没有简单的方法来获取所选文本的 X/Y 坐标。因为它取决于容器的位置和大小、文本字体、文本布局以及许多其他变量。
关于javascript - 选定的文本和 xy 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4106109/