Thariama
Thariama

Reputation: 50832

getBoundingClientRect() does not exist for safari on ipad. Workaround needed

I just found out that getBoundingClientRect() is a great function and provides what i need (in order to calculate the line of my caret in a contenteditable div). Unfortunatly the function does not exist for safari on ipad. What can i do to get the data getBoundingClientRect() provides?

Upvotes: 0

Views: 1374

Answers (1)

mindandmedia
mindandmedia

Reputation: 6825

since you tagged it jquery, may I suggest looking at offset?

edit: I misread your question, so here some code to hopefully help you anyway:

http://jsfiddle.net/XyJ5r/1/

$(document).ready(function() {
    $('#myid').keyup(function() {
        console.log('press');
        var sel = window.getSelection();
        console.log(sel);
        console.log(sel.focusOffset);
    });
});​

Upvotes: 1

Related Questions