首页 > Web开发 > 详细

delphi的webBrowser操作HTML研究

时间:2014-04-03 19:58:00      阅读:827      评论:0      收藏:0      [点我收藏+]

测试例子:

外网电脑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;

delphi的webBrowser操作HTML研究,布布扣,bubuko.com

delphi的webBrowser操作HTML研究

原文:http://www.cnblogs.com/barryhong/p/3642157.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!