user1137313
user1137313

Reputation: 2410

Delphi interaction with webpage

I am generating a webpage (HTML5) from Delphi (writing HTML code, saving in a temp file then open it with chromium embedded). I need to obtain the div id of the clicked element in the chromium browser.

Can this be achieved?

Code would be something like:

<!DOCTYPE html>
<html>
    <head>
        <title>App title</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1" />
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    </head>
    <body>
        <div data-role="page" id="index">
                    <header data-role="header" data-position="fixed">
                        <h1>App header</h1>
                    </header>
                    <div data-role="content">
                        <img src="images/logo.png" />
                        <b>Autenticate</b>
                        <form method="POST" action="thelogin.php">
                            Name: <input type="text" name="name"><br>
                            Pasword: <input type="password" name="passw"><br>
                            <input type="submit" value="Login" data-inline="true" data-icon="gear">
                        </form>
                    </div>

                    <footer data-role="footer" data-position="fixed">
                        <h1>by me</h1>
                    </footer>
        </div>
    </body>
</html> 

This is just an example. The HTML can contain also Sliders, DatePickers, TextArea, Select menus and so on...

enter image description here

Upvotes: 1

Views: 1414

Answers (2)

user1137313
user1137313

Reputation: 2410

Never mind. I found my solution. It is saving the ID's of all elements added at runtime to a temporary table, then check the clicked element using:

frame.VisitDomProc(OnExploreDOM);

in onLoadEnd of the chromium. And parsing the table for all added elements to see the element with which ID was clicked.

Thanks anyway.

Upvotes: 1

Jeroen Wiert Pluimers
Jeroen Wiert Pluimers

Reputation: 24523

Yes this can be achieved. Your browser has a built-in DOM which you can access through JavaScript.

I'm not into JavaScript, but this code might get you started: onclick Event click Javascript DOM Tutorial

Upvotes: 0

Related Questions