views:

95

answers:

1

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
Miro, I need to know the position of the cursor and not the mouse. Mouse position is provided by the mouse events.
Rajiv
What is difference between cursor and mouse? Do you mean absolute position of cursor on monitor?
Miro
@Miro: He probably means the caret position. Its that little blinking bar, or box, that advances as you type.
Brock Adams
I thought that he wanted position of mouse cursor, but he probably wanted text cursor.
Miro