Sarawut Positwinyu
Sarawut Positwinyu

Reputation: 5042

Show popup with highlighted after highlight text and release dragging mouse

http://msdn.microsoft.com/en-us/vcsharp/aa336760#WhereSimple1

On this page, when the code part being highlight and release mouse, the popup with code will appeared, is it javascript. how to code this ?

Upvotes: 4

Views: 1302

Answers (1)

gilly3
gilly3

Reputation: 91657

Probably attach an event listener to onmouseup and check to see if the currently selected text is within the element, and if so, show the popup, populating it with the selected text. Most of that is pretty straightforward, but the part where you check to see if the text selection is fully contained within your target element will be a bit complex - mostly because you'll be different code for different browsers. For older versions of IE, look at document.selection and document.selection.createRange(). For others (including IE9) look at window.getSelection().

Upvotes: 2

Related Questions