日期:2014-05-17  浏览次数:20887 次

为什么mshtml有的网站可以获取IHTMLInputElement有的却不行?!
 HTMLInputElement userID = (HTMLInputElement)doc.all.item("username", 0);
 userID.value = "ax002";
 HTMLInputElement pwd = (HTMLInputElement)doc.all.item("password", 0);
 pwd.value = "12345678";

网站: mail.163.com可以获取HTMLInputElement。
网站: http://www.chinaacc.com/却得不到,为什么?


同样都是 input ,name都为 username。

163的网站源代码:(部分)
<div class="loginForm">
<form id="login163" name="login163" method="post" action="http://mail.163.com/" target="frameforlogin">
<input type="hidden" id="savelogin" name="savelogin" value="0" />
<input type="hidden" id="url2" name="url2" value="http://mail.163.com/errorpage/err_163.htm" />
<div id="idInputLine" class="loginFormIpt showPlaceholder" style="margin-top:32px;">
<input class="loginFormTdIpt" tabindex="1" title="请输入帐号" id="idInput" name="username" type="text" maxlength="50" value="" style="width:145px;" />

chinaacc的源代码:
<div>
<form name="login_form" action="http://portal.cdeledu.com/auth/index.php" method="post" target="_top" onSubmit="return checkdata()">
  <ul class="login">
<li>学员代码
  <input name="username" id="username" class="button" type="text" onclick="changeCode();"/>
</li>
<li>密  码
  <input name="passwd" id="passwd" class="button"  type="password" maxlength="18" />
</li>
<li>验 证 码<input name="randcode" id="randcode" class="check" type="text" maxlength="4" style="width:30px; margin-left:6px;"><img src="http://portal.cdeledu.com/auth/randcode.php?id=login" id="randcodeImg" style="padding:0 1px;" onclick="chgverify();"><a onclick="chgverify();">刷新</a>

------解决方案--------------------
chinaacc中是passwd,而不是password
------解决方案--------------------
这样试试:

mshtml.HTMLInputElement uId =(mshtml.HTMLInputElement)doc.getElementById("username");
uId.value = "ax002";