Search code examples
javascriptjqueryiframefckeditor

Is it possible to access the scroll event in FCKEditor textarea?


I can't find this anywhere and I've tried traversing through the iframes to get to the body element that has the html in it.

Basically I have a div with read only text and an fckeditor with the same content on page load. When the page loads the text in the boxes line up visually beside each other. I want to program it so that when the FCKEditor scrolls as the text becomes longer than the height, it will programmatically scroll the read only div so the content still lines up.

Any ideas?

Thanks,

Thomas


Solution

  • I've got your back broheim.

    This is the code to find the contents of the iFrame window which FCKEditor uses.

    $('#cke_contents_content iframe').contents().find('body').html();
    

    From here, you can find the offset() and use position, and scrollTop. These three pieces combined will allow you to find the scrollback position, make a match, then apply that same 'distance' to the scrollTop() on your 'non FCKEditor' div.

    Good luck.