Loading ...
Sorry, an error occurred while loading the content.

How to set focus at the bottom of a RichTextEditor

Expand Messages
  • b_blancett
    Is there a way to set the scrollbar at the end of the RichTextEditor? Everytime editor.setEditorHTML(...) is called it forces the scroll bar to the top of the
    Message 1 of 3 , Jan 6, 2009
    • 0 Attachment
      Is there a way to set the scrollbar at the end of the RichTextEditor?
      Everytime editor.setEditorHTML(...) is called it forces the scroll bar
      to the top of the page, which makes sense for most cases, but I want
      to append some data from the server on a button click without losing
      focus.

      Appreciate any help,
    • Dav Glass
      b_blancett -- You can grab the scrollHeight of the Editor s document and scroll the window like this: (Written without testing..) //myEditor is a reference to
      Message 2 of 3 , Jan 6, 2009
      • 0 Attachment
        b_blancett --

        You can grab the scrollHeight of the Editor's document and scroll the window like this:

        (Written without testing..)

        //myEditor is a reference to your Editor instance
        var newHeight = myEditor._getDoc().body.scrollHeight;
        if (myEditor.browser.webkit) {
              newHeight = myEditor._getDoc().documentElement.scrollHeight;
        }
        myEditor._getWindow().scrollTo(0, newHeight);

        Does that help?
        Dav

        --
        Dav Glass
        davglass@...
        blog.davglass.com


        + Windows: n. - The most successful computer virus, ever. +
        + A computer without a Microsoft operating system is like a dog
           without bricks tied to its head +
        + A Microsoft Certified Systems Engineer is to computing what a
          McDonalds Certified Food Specialist is to fine cuisine  +


        On Tue, Jan 6, 2009 at 10:54 AM, b_blancett <b_blancett@...> wrote:

        Is there a way to set the scrollbar at the end of the RichTextEditor?
        Everytime editor.setEditorHTML(...) is called it forces the scroll bar
        to the top of the page, which makes sense for most cases, but I want
        to append some data from the server on a button click without losing
        focus.

        Appreciate any help,


      • b_blancett
        This worked great, with the disclaimer (Written without testing..) I figured something would be wrong, not the case. thanks for your time. ... the window ...
        Message 3 of 3 , Jan 6, 2009
        • 0 Attachment
          This worked great, with the disclaimer "(Written without testing..)" I
          figured something would be wrong, not the case.

          thanks for your time.

          --- In ydn-javascript@yahoogroups.com, "Dav Glass" <davglass@...> wrote:
          >
          > b_blancett --
          >
          > You can grab the scrollHeight of the Editor's document and scroll
          the window
          > like this:
          >
          > (Written without testing..)
          >
          > //myEditor is a reference to your Editor instance
          > var newHeight = myEditor._getDoc().body.scrollHeight;
          > if (myEditor.browser.webkit) {
          > newHeight = myEditor._getDoc().documentElement.scrollHeight;
          > }
          > myEditor._getWindow().scrollTo(0, newHeight);
          >
          > Does that help?
          > Dav
          >
          > --
          > Dav Glass
          > davglass@...
          > blog.davglass.com
          >
          >
          > + Windows: n. - The most successful computer virus, ever. +
          > + A computer without a Microsoft operating system is like a dog
          > without bricks tied to its head +
          > + A Microsoft Certified Systems Engineer is to computing what a
          > McDonalds Certified Food Specialist is to fine cuisine +
          >
          >
          > On Tue, Jan 6, 2009 at 10:54 AM, b_blancett <b_blancett@...> wrote:
          >
          > > Is there a way to set the scrollbar at the end of the
          RichTextEditor?
          > > Everytime editor.setEditorHTML(...) is called it forces the scroll bar
          > > to the top of the page, which makes sense for most cases, but I want
          > > to append some data from the server on a button click without losing
          > > focus.
          > >
          > > Appreciate any help,
          > >
          > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.