Last post Nov 08, 2016 10:50 PM by Translating-it
May 24, 2016 09:03 PM|Translating-it|LINK
I'm comparing 2 texts they will either be displayed in a two column table within a textbox or directly in a table on the page iteself. I guess it will be the latter one due to selection issues within the textbox that far. If there is a better way than a
table then please let me know.
So let's say I have a table with one row and 2 columns for my example:
cell 1 // cell 2
Hello, here I am. // Hallo, hier bin ich.
What I now want to do is select/highlight e.g. "Hello" from cell 1 and "Hallo" from cell 2. Selection of words is done with the help of CTRL + mouse selection. This is already tricky as quite often the selection of the first selected word or words is lost
The selection in both cells can be one or more words respectively and they do not need to be in a row. e.g. I introduce my wife to my friends. // Ich stelle meine Frau meinen Freunden vor.
For this example introduce would match stelle vor (introduce = stelle vor) so I would need to get "introduce" from 1 and "stelle" and "vor" from 2.
these two fields?
Anyone got an idea how to best solve this or where I can find something similar on the net?
Thanks in advance,
May 25, 2016 12:12 AM|shivigupta31web|LINK
If I understood your requirement, I believe you are trying to get the text that user selects, i am not sure how to highlight that particular text in a paragraph or table columns. Please use the following code and test it:
<meta name="viewport" content="width=device-width">
<title>Get User Selection</title>
var range = window.getSelection().getRangeAt(0),
content = range.extractContents(),
span = document.createElement('SPAN');
var htmlContent = span.innerHTML;
what is up lads?
what is my name?
<button onclick="getSelectedText()">Click me</button>
here, i am selecting a text, and then clicking on the button to append the selected text into a div element.
Hope this helps.
Jun 12, 2016 01:41 PM|Translating-it|LINK
As I wrote: I know how to get selected text, the question is if my question can be solved with a one click solution. Getting the various text parts with more than one click would not be very user friendly although at the moment it seems the best solution.
Nov 04, 2016 11:12 AM|Translating-it|LINK
I was just wondering, could this be done with frames or something similar?
If I check https://jsfiddle.net/julmot/vpav6tL1/ for example, I can select words in the different parts of the page, just like I would like to do on my page. I just need to find out how they did that. Maybe
you can help here.
Nov 06, 2016 11:01 AM|Translating-it|LINK
Forget about the frames, it seems it's a "side effect" of Codemirror. Is Codemirror the only editor leading to the behaviour, that you can select text in the or each single editor and once outside the editors without the highlighting being lost?
Nov 06, 2016 08:33 PM|bruce (sqlwork.com)|LINK
the standard browser behavior, is that a window can only have one selection (most browser only support a single select range even with code). if a page has multiple windows via iframes, than each window can have one selection.
if iframes don't work, you will need to write your own selection and selection display logic.
Nov 07, 2016 09:10 PM|Translating-it|LINK
iframes don't seem to work. The problem is that I don't really know how to write such a logic. Up to know I only managed to write a logic to select everything between a tag pair with double click, but I guess it won't be that easy. ;)
Could you give me a hint on where to find examples or tutorials?
Nov 08, 2016 10:50 PM|Translating-it|LINK
Forget my previous post, at least part of it ;)
Iframes do the trick (I had used some wrong code) but I still would be interested in how to code an own logic for selections as it would allow me to avoid Iframes which I don't really need in terms of loading another page. It would only be used to display
2 different columns of a table independently, which is not really the purpose they are meant for.