例如:一个网页地址:www.xxx.com/aa.html
内容:<body>
<form   name="form1"   method="post"   action="">   
      <input type=text name=text_name value=''>
      <select   name="select_name">   
          <option   value="v1"   selected>1111111</option>   
          <option   value="v2">sssssss</option>   
      </select> 
  </form> 
</body>怎么在自己DELPHI编写的浏览器中实现:
  点击button1后,edit栏填写‘自动填表’,下拉单选择‘sssssss’呢?大家给些参考哇。

解决方案 »

  1.   

    http://www.pconline.com.cn/pcjob/process/other/borland/0411/500407.html
      

  2.   

    var    hform:IHTMLFormelement;    hdoc:ihtmldocument2;    hall:ihtmlelementcollection;    Hinput:IHTMLinputelement;    iw:iwebbrowser2;    hlen,tmploop:integer;    vk:oleVariant;    dispatch:IDispatch;    begin    if Assigned(webbrowse1) then ///保证网页里有内容;即已经打开一个网页!    begin    hdoc:=webbrowse1.document as ihtmldocument2;    hall:=hdoc.get_all;    hlen:=hall.get_length;    ////以上几步的操作为:将浏览器控件里的内容赋给hdoc.取其所有标识,并算出总数;    ////下面的操作为:按总数循环找到用户名和密码的edit;并赋值;    for tmploop:=0 to hlen-1 do    begin    vk:=tmploop;    dispatch:=hall.item(vk,0);    if succeeded(Dispatch.QueryInterface(IHTMLInputelement,hinput)) then    ///如果此标识是一个edit控件.....    begin ////下面这里的uppercase是必需的!防止因大小写的不同而判断失误!    ///下面的"TEXT"是由网页里的内容来确定的.也就是说你要判断就必需根据具体网页代码来!    ///密码框和用户名处是一样的!    if uppercase(hinput.Type_)='TEXT' then hinput.value:='tresss'    else if uppercase(hinput.type_)='PASSWORD' then hinput.value:='tresss';    end;    if succeeded(dispatch.QueryInterface(IHTMLFormElement,hform))       and (uppercase(hform.name)='THEFORM')    then    ///此处是form提交.如果从html发现只有一个form的话那第二个条件是非必需的!    ///而且也不一定要判断name属性,也可以根据其它属性来判断.    Hform.submit;    end; ////for end;    end; //if end;    end;
      

  3.   

    uses MSHTML;procedure TForm1.Button1Click(Sender: TObject);
    var
      vHTMLDocument: IHTMLDocument2;
      vHTMLElementCollection: IHTMLElementCollection;
      vHTMLInputElement: IHTMLInputElement;
      vHTMLSelectElement: IHTMLSelectElement;
    //  vHTMLFormElement: IHTMLFormElement;
    begin
      vHTMLDocument := WebBrowser1.Document as IHTMLDocument2;
      vHTMLElementCollection := vHTMLDocument.all;
      vHTMLInputElement := vHTMLElementCollection.item('text_name', 0) as IHTMLInputElement;
      if Assigned(vHTMLInputElement) then
        vHTMLInputElement.value := '自动填表';
      vHTMLSelectElement := vHTMLElementCollection.item('select_name', 0) as IHTMLSelectElement;
      if Assigned(vHTMLSelectElement) then
        vHTMLSelectElement.selectedIndex := 1;
    //  vHTMLFormElement := vHTMLElementCollection.item('form1', 0) as IHTMLFormElement;
    //  if Assigned(vHTMLFormElement) then
    //    vHTMLFormElement.submit;
    end;
      

  4.   

    谢谢各位了,受启发也找到了一篇不错的文章,贴出来方便其他需要的人方便查找吧。
    http://blog.csdn.net/eulb/archive/2006/12/11/1438960.aspx
      

  5.   

    FillForm 网页文本框填写扩展,在您需要的时候填写数据。可以填写非表单内容。目前仅处理Input、textarea、select标签。
    扩展安装后可以通过菜单“工具” - “FillForm”开始使用,Save是保存,Fill是填写(当然也可以通过快捷键快速操作)。
    要填写必须您事先对该网页的信息已经做了保存。火狐官方安装地址:
    https://addons.mozilla.org/en-US/firefox/addon/160849谷歌托管下载地址:
    http://code.google.com/p/ffextension/downloads关注开发日志:
    http://blog.csdn.net/sysdzw/archive/2010/04/22/5514062.aspx相关说明:
    1.支持快捷键。按Alt+Q填写当前网页内容,按Alt+W保存当前网页信息,要填写必须之前已经保存。
    2.支持中文,如果出现乱码问题请在下面留言告知。
    3.对于保存的数据只是做了初步加密,请谨慎使用,重要信息不建议保存,因为扩展本身就是开放源代码的,所以通过修改代码可以做到一切想做的。
    4.如果需要对代码进行修改,请修改完发送给作者一份,请不要随便修改关于等信息。
    5.所有因使用此扩展而造成的损失由使用者本人承担。
    6.安装即表示你接受了上面的所有要求,否则请从你的存储设备中删除并终止使用。
    有什么建议的可在下面留言,谢谢,欢迎广大网友参与到FillForm的开发与完善中来,凡是对FillForm有所帮助的都将会被添加到贡献者列表中。图例:
    1.安装后在浏览器中的位置:
    2.关于对话框
    3.当对一个没有保存过信息的网页进行填写操作时会弹出如下提示框
    4.当对一个已经保存过信息的网页再次进行保存操作时会弹出如下对话框