Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, is there any way to get the selected DOM node when we select a part of a web page in WebBrowser control?
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jul-11 0:26am    
Not quite clear, see the answer.
--SA

1 solution

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.

—SA
 
Share this answer
 
Comments
[no name] 20-Jul-11 0:43am    
Perfect +5.
Sergey Alexandrovich Kryukov 20-Jul-11 0:43am    
Thank you, Ramalinga.
--SA
Amir Hossein Farhangi 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 ;).
Sergey Alexandrovich Kryukov 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: http://en.wikipedia.org/wiki/Comparison_of_web_browser_engines.
--SA
Amir Hossein Farhangi 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.

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