我用webBrowser控件获得了163邮箱界面,我想自动填充用户名这个文本框,我用下面的代码填充了文本框for (int i = 0; i < doc.All.Count - 1; i++)
          {
              if (doc.All[i].TagName.Equals("input"))
              {
                 vTag = doc.All[i];
                  if (vTag.Name == "inp_uname")
                  {
                      vTag.SetAttribute("value", "wsjhuhu");                  }                
                                }
          }但是还需要把光标移入文本框,再移出,然后再选择邮箱的类型!我想直接填充好163邮箱,就是直接显示[email protected]望大家不吝赐教!先谢谢了!!!!!

解决方案 »

  1.   

    用webBrowser找到那个控件(通过控件id来查找),然后调用该HtmlElement.InvokeMember函数来模拟执行该控件的操作,
      

  2.   

    默认情况下AutoComplete是打开的
      

  3.   

    function fInitUserName()
    {
    var fm = window.document.login163;
    var name = "";
    if( visitordata.data != null)
    {
    name = visitordata.data[0][0];
    //fm.remUser.checked = true;
    fm.username.autocomplete="on";
    //fm.secure.checked = (visitordata.data[0][3]==1);
    }else{
    fm.username.autocomplete="off";
    //fm.remUser.checked = getCookie("ntes_mail_noremember")!="true";
    } if( name != ""){
    fm.username.value = name;
    setTimeout(function(){
    fm.password.focus();
    },200);
    }else{
    setTimeout(function(){
    fm.username.focus();
    },200);
    }
    }
      

  4.   

    function fCheckAutoLoginCookie(){
    try{
    var sSInfo = getCookie("S_INFO");
    var sPInfo = getCookie("P_INFO");
    var sEmail = "",sTime = "",sState = "",nTimeDiff=0;
    if(sPInfo){
    var aInfo = sPInfo.split("|");
    sEmail = aInfo[0];
    sTime = aInfo[1];
    sState = aInfo[2]; nTimeDiff = (new Date()).getTime()-(sTime+"000");
    }
    if(!location.hash&&sEmail.indexOf("@163.com")>-1&&sState=="1"&&nTimeDiff<14*24*60*60*1000){
    location.href='http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1';
    }
    }catch(exp){}
    }
      

  5.   


                HtmlDocument doc = webBrowser1.Document;
                HtmlElementCollection htmlcollection;
                htmlcollection = doc.GetElementsByTagName("input");
                foreach (HtmlElement he in htmlcollection)
                {
                    if (he.Name == "username")
                    {
                        he.SetAttribute("value", "test");
                    }
                }