SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rich Text Editor and Cursor

    Hi, for my rich text editor, I am using var cursor = idContent.document.selection.createRange();, and then it opens a dialog, and the dialog returns arr, and then I add the value to the rich text editor using cursor.pasteHTML(arr);. That works fine, but when the user doesn't click in the rich text editor first, it pastes the value into my page. How can I have it check if it is in the rich text editor? If it isn't I want it to focus in the rich text editor so the cursor is in there. Any help is apreshiated!

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Call range.parentElement() to retrieve the tag under cursor. Then use contains() to check if this tag is within your editable div:

    Code:
    var oRng=document.selection.createRange();
    if(myEditableDiv.contains(oRng.parentElement()))
         okay.....
    http://msdn.microsoft.com/workshop/a...telement_1.asp

    http://msdn.microsoft.com/workshop/a...s/contains.asp

  3. #3
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •