0
$(document).ready(function () {
    $('#textEditor').contents().keypress(function (e) {
        if (e.which == 35) {
            alert('# pressed');
            //How to get '#' character offset relative to an iframe
        }
        return true;
    });

#textEditor是我在代码中使用的iframe的id

编辑: xy 坐标的偏移量,而不是 iframe 开头的字符数

提前致谢。

4

1 回答 1

0
var selection = window.getSelection();
var range = selection.getRangeAt(0);
console.log(range.getBoundingClientRect()); // left, top, height, width
于 2013-10-16T12:09:36.667 回答