Click here to Skip to main content
13,001,686 members (103,491 online)
Rate this:
Please Sign up or sign in to vote.
Hi, is there any way to get the selected DOM node when we select a part of a web page in WebBrowser control?
Posted 19-Jul-11 1:36am
SAKryukov 20-Jul-11 0:26am
Not quite clear, see the answer.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If I understand this right you mean selection with the mouse, something you do before the clipboard "Copy" operation. The problem is: such selection does not select any certain node. It selects a fragment of the document in its rendered form, not DOM; such selection goes across the DOM nodes of different levels. For example, it can select part of paragraph, several nested tables with images and a part of anchor. I don't think the whole idea of such selection reflects the DOM structure or can be applicable to it.

Ramalinga Koushik 20-Jul-11 0:43am
Perfect +5.
SAKryukov 20-Jul-11 0:43am
Thank you, Ramalinga.
KAMRAN00F 20-Jul-11 16:08pm
Oh yes, you are right. So let's change the question; Getting the DOM node of the htmlNode that the mouse is over it, or is clicking on it. When a mouse is pointing somewhere in the web page, it is exactly on 1 html element (e.g. Text, or link or image...) so I think in this situation we can get the DOM node.

Actually there is a program that it does what I exactly want. It's "Visual Web Ripper" and you can download a trial version of that from here:
Download Visual Web Ripper 2.76.5 (zip file, 6MB)

I need same thing. That would be a grate help. Thx ;).
SAKryukov 20-Jul-11 22:01pm
Yes, this should be possible in principle, but if existing HTML rendering engines do not provide this functionality (they do not obliged to provide it as there are no standards that would require it), it would mean creating a custom HTML rendering engine. If you look at WebBrowser IE-based control you will see that click and mouse click events are not supported and selection of cursor position is not supported. This is what you would really need as a minimum, but not supported.

You can look at open source HTML rendering engines, look at source code and get some understanding of how to approach to the problem:
KAMRAN00F 21-Jul-11 6:14am
I was thinking about what you said, you are right! I need an html renderer, thank you very much for the help. I will try it.
deshmukhsc 13-Sep-11 4:55am
Any update on this question I am aslo looking for same

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 20 Jul 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100