1

我正在从 Delphi 生成一个网页(HTML5)(编写 HTML 代码,保存在临时文件中,然后用嵌入的铬打开它)。我需要在 chromium 浏览器中获取被点击元素的 div id。

这可以实现吗?

代码将类似于:

<!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> 

这只是一个例子。HTML 还可以包含 Sliders、DatePickers、TextArea、Select 菜单等...

在此处输入图像描述

4

2 回答 2

1

没关系。我找到了我的解决方案。它将运行时添加的所有元素的 ID 保存到临时表中,然后使用以下命令检查单击的元素:

frame.VisitDomProc(OnExploreDOM);

在铬的 onLoadEnd 中。并解析所有添加元素的表格以查看单击 ID 的元素。

不管怎么说,还是要谢谢你。

于 2013-09-12T22:00:16.607 回答
0

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

于 2013-09-12T16:03:53.320 回答