Welcome Guest Search | Active Topics | Sign In | Register

How to get the selected text on web view Options
Khoa
Posted: Thursday, October 2, 2014 6:25:53 PM
Rank: Advanced Member
Groups: Member

Joined: 9/3/2014
Posts: 68
Hi,

I am looking a way to get selected text on the web view of EO.WebBrowser, but cannot find it. Could you please help me how to get selected text on web view, not the whole text of the web view.

Thanks.
eo_support
Posted: Friday, October 3, 2014 1:09:00 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

The WebView does not expose any methods for you to get that directly. However you can search online to find the correct JavaScript code to do it and then call EvalScript to return that value from JavaScript to your .NET code. See here for more information on how to use EvalScript here:

http://www.essentialobjects.com/doc/6/advanced/js.aspx#evalscript

Thanks!
Khoa
Posted: Friday, October 3, 2014 10:16:37 PM
Rank: Advanced Member
Groups: Member

Joined: 9/3/2014
Posts: 68
EvalScript does a trick for me. Thank you for your hint.
Jason R.
Posted: Friday, June 19, 2015 12:04:57 PM
Rank: Member
Groups: Member

Joined: 6/12/2015
Posts: 20
This works great in most cases: EvalScript("window.getSelection().toString();")

However, chrome returns a empty string when using this during BeforeContextMenu

I cannot for the life of me figure out a way to get the Selected Text in the BeforeContextMenu event.

eo_support
Posted: Friday, June 19, 2015 3:45:51 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Jason R. wrote:
This works great in most cases: EvalScript("window.getSelection().toString();")

However, chrome returns a empty string when using this during BeforeContextMenu

I cannot for the life of me figure out a way to get the Selected Text in the BeforeContextMenu event.



Currently there is no way to get the selection from inside BeforeContextMenu handler. This is explicitly prohibited in our code because of the potential of causing an internal deadlock. We do understand that there is a need to support this inside BeforeCotnextMenu, so we will look into it and see if we can find any clean workaround.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.