突出显示文本时获得光标的位置
我需要创建一个人们可以用来查找单词的 chrome扩展名。而且我发现我使用双击方法,例如当我想找到一个单词的含义时,我只需双击,然后出现通知。 (下图是我的chrome扩展。)
- 但是,我发现用户很难找到Pharsal的含义 动词,搭配和句子。
- 所以想出一个想法,我可以在 用户选择文本,以及本文的最后一封信,我得到 位置。
- 此外,我还发现了许多其他Chrome扩展支持 这个功能,它们真是太好了!其中之一是“边缘翻译”。当我欣赏文本,然后释放鼠标时,它会出现一个小弹出球,然后单击该球,它会出现面板。这是他们的扩展: “ nofollow noreferrer>” google.com/webstore/detail/Edge-translate/bocbaobfecmglnmeaeepamepameimao?hl = en
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要获取选择的文本,您可以使用此功能,然后删除点,以及您不感兴趣的其他字符,然后按空格将所选文本拆分以获取最后一个单词。 (也不需要光标坐标,因此您可以删除该件。
To get the text selected you could use this function, then remove the dots, and other characters you are not interested in and split the selected text by spaces to get the last word. (also you don't need the cursor coordinates for it, so you could remove this piece. of the code)
感谢您的贡献,我在Mouseup活动中找到了解决方案。
Thanks for your contribution, I have found the solution with onMouseUp Event.