Delphi_判断Webbrowser打开的网页组件是否存在?
2016-05-13 11:43
429 查看
网页代码:
[html] view
plain copy
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script>
function aa(){
alert("abc");
}
</script>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
<p><input type="button" value="按钮" name="B3" onclick="aa()"></p>
</form>
</body>
</html>
delphi判断网页中是否存在某个名字的控件
[delphi] view
plain copy
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHTML_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Math;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('c:\index.htm');
end;
procedure TForm1.Button1Click(Sender: TObject);
var b:IHTMLElement;
begin
b:=(WebBrowser1.Document as IHTMLDocument3).getElementById('B3');
if b=nil then exit;//这里判断网页中是不是找到了这个按钮,如果换成B4就不能执行下面的代码了
b.click;
end;
end.
[html] view
plain copy
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script>
function aa(){
alert("abc");
}
</script>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
<p><input type="button" value="按钮" name="B3" onclick="aa()"></p>
</form>
</body>
</html>
delphi判断网页中是否存在某个名字的控件
[delphi] view
plain copy
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHTML_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Math;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('c:\index.htm');
end;
procedure TForm1.Button1Click(Sender: TObject);
var b:IHTMLElement;
begin
b:=(WebBrowser1.Document as IHTMLDocument3).getElementById('B3');
if b=nil then exit;//这里判断网页中是不是找到了这个按钮,如果换成B4就不能执行下面的代码了
b.click;
end;
end.
相关文章推荐
- DELPHI 线程池代码
- Delphi下获取系统默认的UserAgent的方法
- Delphi之接口
- Delphi之多线程实例
- delphi的取整函数round、trunc、ceil和floor
- Delphi的学习笔记十七——Exception处理
- Delphi学习笔记一——单元文件(补充)
- delphi概念性学习(三)
- 解决DELPHI的程序占内存的代码
- DELPHI基于线程的定时器和一个泛型对象池
- Delphi对象池
- delphi概念性学习(二)
- delphi7生成简单的验证识别码
- Delphi 7 在WIN764位上调用webservice 发生 access violation at address
- delphi 10.1 berlin最新的开发框架:咏南中间件+咏南开发框架,购买后提供全部的源码
- delphi7运行关闭出现cannot creat file"C:\program file\borland\delphi7\bin\initcc32.exe拒绝访问
- delphi inttohex 整型到十六进制
- delphi的^和@的作用
- Delphi 7.0 快捷键发生混乱解决办法
- Delphi berlin 如何自定义Listview外观样式