Get text in CSS3 column?

I use CSS3 support to support columns in the project (so far I have found it much more reliable and reliable than most JavaScript solutions).

Question: Is there any way to get text that is in a certain column?

+6
source share
2 answers

And ... what, in two months? Finally, I found the answer to this question. It depends on document.caretRangeFromPoint (Webkit) or document.caretPositionFromPoint .

var getAllTextInColumn = function(rect){ /* rect should be the size and x,y of the column { top, left, width, height } */ if(document.caretRangeFromPoint){ var caretRangeStart = document.caretRangeFromPoint(rect.left, rect.top); var caretRangeEnd = document.caretRangeFromPoint(rect.left+rect.width-1, rect.top+rect.height-1); } else { return null; } if(caretRangeStart == null || caretRangeEnd == null) return null; var range = document.createRange(); range.setStart(caretRangeStart.startContainer, caretRangeStart.startOffset); range.setEnd(caretRangeEnd.endContainer, caretRangeEnd.endOffset); return range.toString(); }; 
+7
source

My only assumption is to start replacing the spaces with SPAN , and then determine when the vertical position of this SPAN becomes smaller, then you know that you are in the next column. This last SPAN becomes a column marker.

Then you can copy the text that is between the beginning / end and / or the creator of the column.

+1
source

All Articles