Page 1 of 1
Getting name of element when mouse is clicked
Posted: Wed Feb 26, 2020 9:13 am
by softtouch
How can I get the name of the element when I click on a webpage with the mouse, without using DOM?
I guess I could somehow use javascript, but how and if, how can I get the value back to Delphi to process the value?
Re: Getting name of element when mouse is clicked
Posted: Wed Feb 26, 2020 10:47 am
by salvadordf
Hi,
There are several ways to do that.
- Use the GlobalCEFApp.OnFocusedNodeChanged event and read the node.name value. This event is executed in the render process and you will need to send a process message with the node name value to the browser process.
- Use JavaScript to get the node under the coordinates of the last mouse click and use a JavaScript extension to send the node name to the browser process.
Almost all the code you need is already in the JSExtension or JSRTTIExtension demos. Read the code comments in the JSExtension demo for a detailed explanation.