• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

delphi的webBrowser操作HTML研究

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

测试例子:

外网电脑D:\TEST\delphiTest\webbrowsetest

参考文档:

delphi 操作WebBrowser 元素值
http://hi.baidu.com/kinglike/item/c4608a8e55313f874514cf5c

delphi中WEBBrowser网页JS函数调用delphi函数
http://blog.csdn.net/iseekcode/article/details/4740269

webbrowser精华内容
http://blog.csdn.net/iseekcode/article/details/4740367

delphi 向webbrowser打开的网页中插入js命令
http://blog.csdn.net/iseekcode/article/details/4740286

 

1.获取WEB控件值

function TForm1.fgetValue(editName: string): string;
var
  i:integer;
  Doc:IHTMLDocument2;
  input:OleVariant;
  userinputelement,pwdinputelement,ValidateElement:ihtmlinputelement;
  ValidateImage: IHTMLImgElement;
  imagecount:integer;
  form:ihtmlformelement;
  myitem:Olevariant;
begin
Doc:=WebBrowser1.document as ihtmldocument2;
  if doc=nil then exit;

// 第一种方式
  userinputelement:=(doc.all.item(editName,0) as ihtmlinputelement);
  Result :=  userinputelement.value;


end;

2.设置WEB控件值

procedure TForm1.setValueClick(Sender: TObject);
var
  i:integer;
  Doc:IHTMLDocument2;
  input:OleVariant;
  userinputelement,pwdinputelement,ValidateElement:ihtmlinputelement;
  ValidateImage: IHTMLImgElement;
  imagecount:integer;
  form:ihtmlformelement;
  myitem:Olevariant;
begin
Doc:=WebBrowser1.document as ihtmldocument2;
  if doc=nil then exit;

// 第一种方式
  userinputelement:=(doc.all.item('userName',0) as ihtmlinputelement);
  userinputelement.value:='ADMIN';

  userinputelement:=(doc.all.item('password',0) as ihtmlinputelement);
  userinputelement.value:='1';


end;

3.WEB调用DELPHI

procedure TForm1.WebBrowser1BeforeNavigate2(ASender: TObject;
  const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);
begin
//  showmessage(url);
  if pos('qwbbLocatePage.action', url) > 0 then
  begin
    ShowMessage(fgetValue('userName'));
    Cancel:= true;
  end;
end;


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap