急急急!!!如何使用js实现自动填写网页内容并提交,分数不够可以再加,拜托了!!
现在我有一个系统登录页面,用户名、密码以及登录按钮,如何在输入框中自动填入相应用户名、密码,然后自动实现登录按钮的点击动作!
以下是html源文件
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
<script type= "text/javascript " language= "javascript ">
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:Label ID= "Label1 " runat= "server " Text= "用户名: "> </asp:Label>
<asp:TextBox ID= "txtUserName " runat= "server "> </asp:TextBox> <br />
<br/>
<asp:Label ID= "Label2 " runat= "server " Text= "密码: "> </asp:Label>
<asp:TextBox ID= "txtUserPwd " runat= "server "> </asp:TextBox> <br />
<asp:Button ID= "btnLogin " runat= "server " OnClick= "btnLogin_Click " Text= "登录 " /> </div>
</form>
</body>
</html>
------解决方案-------------------- <script language= "javascript ">
function submitForm(){
document.getElementById( "txtUserName ").value= "username ";
document.getElementById( "txtUserPwd ").value= "userpwd ";
document.getElementById( "btnLogin ").click();
}
window.onload=submitForm;
</script>
//加到head里就行了