Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Aug 2004
    Twin Cities
    Thanked 0 Times in 0 Posts

    find out the node/element that the cursor is in

    so I am using the Rich Text Editor located here:
    and here

    anyway, I am building 'improved' table functionality.. right now I'm stuck on how I can retreive the node the cursor is a child of.
    I am able to insert a table with both IE and Mozilla and I am able to modify the attribute of a TD elment in this fashion with IE:
    	oRTE = frames[rte]
    	var selection = oRTE.document.selection; 
            rng = selection.createRange()
    so then I am able to modify the attributes of a TD in any manner that I choose-- it'll probably end up being a layer/popup for a user to edit the 'desired' attributes.

    But, I have been struggling trying to find a solution that would work with Mozilla. I wish it was as simple as 'getSelectedElement' .. and I try the getRangeAt() function with 0 as the argument and that claims to not be defined but it seems to work elsewhere in the script(it is not a typo, I'm not dyslexic and it still says it's undefined).

    If I need to upload sample code for you to see what I'm doing better, let me know.

  2. #2
    Join Date
    Sep 2003
    Thanked 0 Times in 0 Posts
    Hi and Welcome to Coding Forums...

    I recieved your P/M and I believe your problem is that Mozilla will consider whitespace as a textnode so if you are trying to walk up the tree one node, you may find yourself in an empty textnode...

    And although I graciously accept your compliment, JKD knows more about this than I do and provided a good explanation of empty textnodes here....

    Also, at one time, Alex Vincent posted a Mozilla whitespace removing code and the link may be found in the above link.... If not, try searching on Alex's username in the Post A Javascript forum...



Posting Permissions

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