Hello. Tell me how to get the text selection? There is a function containing this code:
if (window.getSelection) { return window.getSelection(); } else if (document.getSelection) { return document.getSelection(); } else if (document.selection) { return document.selection.createRange().text; } else { return 0 };
It is called by clicking on the desired link, but returns nothing. The console did not give any errors. As it seems to me, the problem is that after clicking on the link, all the selected text is “reset” and only then my function starts. How to solve a similar problem?