Is there a cross browser way to find the XY coordinates of the caret (as opposed to the mouse position, which is provided by mouse events) in an editable iframe on key events?
A:
I've found this: http://www.codelifter.com/main/javascript/capturemouseposition1.html, in iframe mouse position is relative to iframe position:
<html>
<body>
<iframe src ="http://www.codelifter.com/main/javascript/capturemouseposition1.html" style="position:relative;left:25%;width:75%;height:500px">
</iframe>
</body>
</html>
The detection of mouse position you can find at page which i've wrote.
EDIT: I've find this article: http://parentnode.org/javascript/working-with-the-cursor-position/. And read comments, because there are fixed some bugs. Maybe it will help you :)
Miro
2010-08-09 18:10:40
Miro, I need to know the position of the cursor and not the mouse. Mouse position is provided by the mouse events.
Rajiv
2010-08-10 05:11:36
What is difference between cursor and mouse? Do you mean absolute position of cursor on monitor?
Miro
2010-08-11 14:23:56
@Miro: He probably means the caret position. Its that little blinking bar, or box, that advances as you type.
Brock Adams
2010-08-19 18:48:28
I thought that he wanted position of mouse cursor, but he probably wanted text cursor.
Miro
2010-08-20 09:14:41