测试例子:

外网电脑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. jQuery延迟加载(懒加载)插件 – jquery.lazyload.js

    引入:<script type="text/javascript" src="${base}/resources/shop/js/jquery.lazyload.j ...

  2. iOS 中实现功能引导页面

    // //  guideView.h //  07-功能引导-李洪强 // //  Created by vic fan on 16/1/4. //  Copyright © 2016年 李洪强. A ...

  3. pdf转word

    一.刚需 pdf转word,这个需求肯定是有的.但是大家都知道,pdf是用来排版打印的,所以编辑起来会比较麻烦,所以,大家都会尝试将pdf的内容转成word,然后再进行编辑. 二.方法 1.用offi ...

  4. [CareerCup] 18.8 Search String 搜索字符串

    18.8 Given a string s and an array of smaller strings T, design a method to search s for each small ...

  5. MRP运算生成采购单时间的逻辑

    由MRP运算产生的采购单日期,由生产单指定的安排计划日期.公司设置里的采购提前期和隐藏的供应商供货提前期三个字段共同决定. 可以很容易的在系统中找到,供应商供货提前期,需要在产品视图中将字段selle ...

  6. thinkphp自定义分页效果

    TP自带了一个分页函数,挺方便使用的. 下面是我的使用方法: /*****************分页显示start*************************/ $arr_page=$this ...

  7. zk回车事件

    private Textbox testTextB; testTextB.addEventListener(Events.ON_OK, new EventListener<Event>() ...

  8. php Use of undefined constant的问题解决方式

    在每个文件头上加 error_reporting(0); 或者 搜索php.ini: error_reporting = E_ALL 改为: error_reporting = E_ALL & ...

  9. in_array支持第三个参数,强制对数据类型检测

    in_array函数是判断数据中是否存在指定的内容了,对于这个函数用法非常的简单但在使用过程中会我发现有一些问题. 先介绍一下需求背景: 发票方式: 0=捐赠(不要问我为什么,历史原因) 1=对中寄送 ...

  10. Yii源码阅读笔记(二十一)——请求处理流程

    Yii2请求处理流程: 首先:项目路径/web/index.php (new yii\web\Application($config))->run();//根据配置文件创建App实例,先实例化y ...