Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how can i get the selected text of a web page using webKitBrowser?


here is the old code of the default browser:
C#
IHTMLDocument2 htmlDocument = webBrowser1.Document.DomDocument as IHTMLDocument2;

IHTMLSelectionObject currentSelection = htmlDocument.selection;

            if (currentSelection != null)
            {
            IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;

                if (range != null)
                {
                   string browserSelectedText = range.text;
                }
            }
Posted
Updated 10-May-13 5:31am
v2
Comments
Sunasara Imdadhusen 21-May-13 3:56am    
Are you getting any error?
Nnorss 22-May-13 6:55am    
This is an old post... The solution is very simple : string browserSelextedText = webKitBrowser1.SelectedText;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900