document.selection, get full text for container element

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • citron
    New Member
    • Apr 2010
    • 1

    #1

    document.selection, get full text for container element

    I would like to get the full text content inside an element, even if only a part of the text is selected.

    Would be possible to modify this code some how to take this into account?


    Code:
    if (window.getSelection){
    	        selection=window.getSelection();
    	    }
    	    else if (document.getSelection){
    	        selection=document.getSelection();
    	    }
    	    else if (document.selection){
    	        selection=document.selection.createRange();
    	    }
    alert(selection);
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    if you want something beyond the selection, you can’t use the Selection object directly. I’d try getting the Node of the selection and use .textContent.

    Comment

    Working...