gpt4 book ai didi

javascript - 文本光标/插入符号在关键事件的可编辑 iframe 中的 XY 位置

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:47:23 26 4
gpt4 key购买 nike

是否有一种跨浏览器的方法可以在关键事件的可编辑 iframe 中找到插入符的 XY 坐标(与鼠标位置相对,鼠标位置由鼠标事件提供)?

最佳答案

我找到了这个:http://www.codelifter.com/main/javascript/capturemouseposition1.html ,在 iframe 中鼠标位置是相对于 iframe 位置的:

<html>
<body>

<iframe src ="http://www.codelifter.com/main/javascript/capturemouseposition1.html" style="position:relative;left:25%;width:75%;height:500px">
</iframe>

</body>
</html>

你可以在我写的页面上找到鼠标位置的检测。

编辑:我找到了这篇文章:http://parentnode.org/javascript/working-with-the-cursor-position/ .并阅读评论,因为修复了一些错误。也许它会对你有所帮助:)

关于javascript - 文本光标/插入符号在关键事件的可编辑 iframe 中的 XY 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3074618/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com