下面这种方法对PHP文件无效,一般网页就可以实现!var
Docs, Edits : OleVariant;
begin Docs :=WebBrowser1.Document; Edits :=Docs.GetElementByID('action');
Edits.Value :='您的帳號';
Edits :=WebBrowser1.OleObject.Document.all.Item('password', 0);
Edits.Value :='您的密碼'; //登入
WebBrowser1.OleObject.Document.GetElementByID('Login').Click;
end;
Docs, Edits : OleVariant;
begin Docs :=WebBrowser1.Document; Edits :=Docs.GetElementByID('action');
Edits.Value :='您的帳號';
Edits :=WebBrowser1.OleObject.Document.all.Item('password', 0);
Edits.Value :='您的密碼'; //登入
WebBrowser1.OleObject.Document.GetElementByID('Login').Click;
end;
解决方案 »
- Delphi如何对数据库循环?
- 请教高人,如何自动去执行程序?
- Stringgrid的简单问题
- C/S结构数据库程序问题?
- SQL的问题!请尽快帮我解决呀!!!!!
- 怎么动态改变窗体和控件的大小而使他们之间的相互之间的相对位置不变?
- 通过API获得某个窗体的HANDLE,再通过TCANVAS向该窗体画图,但该窗体不会AUTOREDRAW(该窗体只知道他的HANDLE)
- delphi数据库中关于图像存取的知识
- :PageControl的PageControl1DrawTab事件 好像每时每刻都在运行,能不能让它在程序启动时值运行一次。在这次就确定好TextOut的位置。谢谢。
- 我下的《delphi 5开发人员指南》为什么打开时会这样?
- 关于ADOQUERY的问题
- 关闭MDI窗口问题~~~在线等
var
SList: TStringList;
PostStr: String;
i: Integer;
PostData,Headers: OleVariant;
begin
SList := TStringList.Create;
try
SList.Add('http://community.csdn.net/expert/forum.asp');
PostStr := 'login_name=' + EditUserName.Text;
PostStr := PostStr + '&password=' + EditPassword.Text; Headers := 'Content-Type: application/x-www-form-urlencoded'+ #10#13;
PostData := VarArrayCreate([0, Length(PostStr)-1], varByte);
for i := 0 to Length(PostStr)-1 do begin
PostData[i] := Ord(PostStr[i+1]);
end;
WebBrowser1.Navigate(SList.Strings[0],EmptyParam,EmptyParam,PostData,Headers);
finally
SList.Free;
end;
end;(注:在EditUserName.Text和EditPassword.Text中
録入NI在CSDN的Username和Password就会進入"欢迎您:hub1972 ")
<head>
<title>SK2</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style/control/control_main.css" rel="stylesheet" type="text/css">
<script language=javascript>
function new_win(html_name,winname,w,h){
if(winname=='') winname='WINDOWS';
if(w=='') w=640;
if(h=='') h=480;
//undefined
winformat="toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+w+",height="+h;
winid = window.open(html_name,winname,winformat)
}
</script>
</head><body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="100">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="332">
<tr>
<td width="8%"><img src="images/index-1.gif" width="90" height="332"></td>
<td width="14%">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="javascript:new_win('contact.php','contact','570','440')"><img src="images/index-2.gif" width="151" height="174" border="0"></a></td>
</tr>
<tr>
<td><img src="images/index-22.gif" width="151" height="158"></td>
</tr>
</table>
</td>
<td width="15%">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/index-3.gif" width="159" height="174"></td>
</tr>
<tr>
<td><img src="images/index-33.gif" width="159" height="158"></td>
</tr>
</table>
</td>
<td width="9%"><img src="images/index-4.gif" width="97" height="332"></td>
<td width="6%">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/index-5.gif" width="242" height="69"></td>
</tr>
<tr>
<td width="242" height="105" background="images/index-51.gif">
<FORM name=login action="chk_rule.php"
method=post>
<table border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" nowrap class="title_02">帐号:
</td>
<td valign="middle">
<div align="left"> </div>
<INPUT type=hidden value=login name=action>
<div align="left">
<INPUT onchange=focuspwd() size=15
name=loginname class="za_text">
</div>
</td>
</tr>
<tr>
<td valign="bottom" nowrap class="title_02">密码:
</td>
<td valign="middle">
<div align="left">
<INPUT type=password onchange=focuslogin()
size=15 name=password class="za_text">
<input type="submit" value="登入" name="login" class="za_button">
</div>
</td>
</tr>
<tr>
<td nowrap class="title_01"> </td>
<td>
<div align="left"> </div>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="242" height="83" background="images/index-521.gif"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="242" height="83">
<param name=movie value="images/urser.swf">
<param name=quality value=high>
<param name="wmode" value="transparent">
<embed src="images/urser.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="242" height="83">
</embed>
</object></td>
</tr>
<tr>
<td width="242" height="75" background="images/index-522.gif" align="center" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20"> </td>
</tr>
<tr>
<td>
<table width="90%" height="22" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center"><a href="?charset=1"><img src="images/chinese-tw.jpg" width="40" height="15" border="0"></a></div>
</td>
<td>
<div align="center"><a href="?charset=2"><img src="images/chinese-cn.jpg" width="40" height="15" border="0"></a></div>
</td> </tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<div align="center"><a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?displaylang=zh-tw&FamilyID=1E1550CB-5E5D-48F5-B02B-20B602228DE6"><img src="images/home_L4_IE-tw.gif" width="101" height="31" border="0"></a></div>
</td>
<td>
<div align="center"><a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=1E1550CB-5E5D-48F5-B02B-20B602228DE6"><img src="images/home_L4_IE-cn.gif" width="101" height="31" border="0"></a></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="48%" background="images/index-xx.gif"><img src="images/index-6.gif" width="39" height="332"></td>
</tr>
</table>
</body>
<SCRIPT language=JavaScript>
<!-- document.login.loginname.focus() function focuspwd()
{
document.login.password.focus();
return(true);
} function focuslogin()
{
document.login.login.focus();
return (true);
} //-->
</SCRIPT>
<script>
document.login.loginname.focus();
</script>
</html>
Docs, Edits : OleVariant;
begin
Docs := WebBrowser1.OleObject.Document; Edits := Docs.getElementsByName('loginname');
Edits.Value :='您的帳號';
Edits := Docs.getElementsByName('password');
Edits.Value :='您的密碼'; Docs.getElementsByName('login').Click;
end;======================================================
<Form name=login action="chk_rule.php" method=post>
<INPUT type=hidden value=login name=action>
<INPUT name=loginname class="za_text">
<INPUT type=password name=password class="za_text">
<input type="submit" value="登入" name="login" class="za_button">
</Form>注:在你的<Form>...</From>中没有用到「Id」、因此不能用GetElementByID、
要用getElementsByName。还有帳號名不对。
var
SList: TStringList;
PostStr: String;
i: Integer;
PostData,Headers: OleVariant;
begin
SList := TStringList.Create;
try
SList.Add('http://www.sk2net.com/chk_rule.php');
PostStr := 'loginname=您的帳號';
PostStr := PostStr + '&password=您的密碼'; Headers := 'Content-Type: application/x-www-form-urlencoded'+ #10#13;
PostData := VarArrayCreate([0, Length(PostStr)-1], varByte);
for i := 0 to Length(PostStr)-1 do begin
PostData[i] := Ord(PostStr[i+1]);
end;
WebBrowser1.Navigate(SList.Strings[0],EmptyParam,EmptyParam,PostData,Headers);
finally
SList.Free;
end;
end;(你用这种方法试一试看行吗? 你的那种方法没有ID不好取数)