测试例子:

外网电脑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研究的更多相关文章

  1. delphi中webbrowser的用法

    WebBrowser1.GoHome; //到浏览器默认主页 WebBrowser1.Refresh; //刷新 WebBrowser1.GoBack; //后退 WebBrowser1.GoForw ...

  2. Delphi中WebBrowser控件打开部分网站报"Invalid floating point operation”解决

    Delphi中WebBrowser控件打开部分网站报"Invalid floating point operation”解决 EmbeddedWBWebBrowserDelphi  最近用E ...

  3. C#的WebBrowser操作frame如此简单

    刚学c#不久,也不太懂什么IHTMLDocument.IHTMLDocument2.IWebBrowser2等等.自己琢磨了好久,终于知道了怎么用WebBrowser操作frame和iframe. 1 ...

  4. HttpWebRequest post 提交 C#的WebBrowser操作frame如此简单 WebClient 提交

    //http://www.cnblogs.com/cgli/archive/2011/04/09/2010497.html System.Net.ServicePointManager.Expect1 ...

  5. Delphi中的操作二进制文件的两个重要函数

    Delphi中的操作二进制文件的两个重要函数 对于通过Byte数组进行文件操作的,在FTP中经常会使用到,我也是在Delphi调用Web Service进行文件的上传和下载时找到这两个函数的,挺好用的 ...

  6. C#的WebBrowser操作frame

    刚学c#不久,也不太懂什么IHTMLDocument.IHTMLDocument2.IWebBrowser2等等.自己琢磨了好久,终于知道了怎么用WebBrowser操作frame和iframe. 1 ...

  7. delphi 文件的操作:重命名、复制、移动、删除

    Delphi 文件的操作:重命名.复制.移动.删除第一种方法: RenameFile('Oldname', 'Newname'); CopyFile(PChar('Oldname'), PChar(' ...

  8. delphi 注册表操作(读取、添加、删除、修改)完全手册

    DELPHI VS PASCAL(87)  32位Delphi程序中可利用TRegistry对象来存取注册表文件中的信息. 一.创建和释放TRegistry对象 1.创建TRegistry对象.为了操 ...

  9. delphi中WEBBrowser网页html相互调用(一)

    1.基本操作1.1.激活 var doc,url:Olevariant ; begin url:='about:blank' ;//或者一个有实际意义的url WebBrowser1.Navigate ...

随机推荐

  1. Eclipse IDE for C/C++ Developers安装配置详解

    Eclipse IDE for C/C++ Developers安装配置详解(转) 转自:http://hi.baidu.com/ltb6w/item/986532efd712460f570f1ddc ...

  2. 在VS2010中创建并引用dll(C#)

    一般情况下,如果在新建或添加时选择“windows应用程序”或“控制台应用程序”时,‎结果都会被编译成exe,而选择“类库”时就会被编译成dll.也可以在项目属性中更改其输出类型,如下图:       ...

  3. Odoo 路线规则实现机制浅析

    事情是这个样子的:项目在实施过程中,碰到A仓库向B仓库供货的情况,心想这还不简单,老老实实地建多个仓库并将B仓库的供货仓库选为A仓库,再设置好产品的再订购规则,万事大吉了.然而,事情并非想象的那么简单 ...

  4. sprin加载顺序

    spring加载有个比较有意思的问题,这里片很不错的文章 http://guoliangqi.iteye.com/blog/632697

  5. MySQL Server-id踩到的坑

    最近踩到一个说大不大,说小不小的坑,在此分享出来给各位同学.事情是这样的,线上有2台服务器,1主1从.A -> B,B服务器从A服务器同步数据.每天使用xtrabackup在B服务器上面进行全备 ...

  6. iOS App TransportSecurity has blocked a cleartext HTTP (http://) resource load since it isinsecure. Temporary exceptions can be configured via your app's Info.plistfile

    “App TransportSecurity has blocked a cleartext HTTP (http://) resource load since it isinsecure. Tem ...

  7. GIT与SVN的区别

    1.GIT是分布式的,SVN不是: 这是GIT和其它非分布式的版本控制系统,例如SVN,CVS等,最核心的区别.如果你能理解这个概念,那么你就已经上手一半了.需要做一点声明,GIT并不是目前第一个或唯 ...

  8. 如何查看JSP和Servlet版本

    我们在java web开发的过程中,有时在资料上可能会提到环境所要支持的JSP,Servlet版本.如果版本低就可能出现测试错误. 方法:打开tomcat的common/lib 目录下,有两个JAR文 ...

  9. Android课程---时间日期对话框

    activity_ui2.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...

  10. 【iCore3 双核心板_FPGA】例程一:认识FPGA

    实验指导书及代码包下载: http://pan.baidu.com/s/1kUa05FL iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...