如何在IE浏览器中实现自动点击(确认)功能?
我上网需要输入在IE中输入用户名和密码,然后点击“连接网络”按钮进行登录才可以正常上网。
而我又只在自己电脑上用,想通过什么办法实现自动点击按钮的操作。
用脚本或者VC/VB能实现这样的功能么?请高人指点。
登录页面源文件如下:
<script language='javascript' src="/check.js">
</script> <html>
<head>
<title>我的网上家园</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="coolmenu.css">
<script language="javascript" src="check.js"></script>
<style type="text/css">
<!--
td { font-size: 12px}
-->
</style>
<script language="javascript">
var oldCookieDate = 3650;
var oldCookieDateIndex = 0;
function useralerm(newCookieDate,newIndex) {
var result = true;
if ((oldCookieDate == 0) && (newCookieDate > 0)) {
result = confirm("您选择了在本地保存用户名和密码,这有可能导致您的账号信息被他人窃取。如果您是在公共场合上网,请不要使用此功能。\n您确定要保存账号和密码吗?");
}
if (result) {
oldCookieDate = newCookieDate;
oldCookieDateIndex = newIndex;
}else {
mainform.cookiedate.options[oldCookieDateIndex].selected = true;
}
return result;
}
function checkvalue(){ if (0 == "1") {
mainform.action="http://172.31.1.21/secu/webLogin.jsp";
} mainform.username.value = trim(mainform.username.value);
if (mainform.username.value != null && mainform.username.value !=""){
//深圳的用户名允许包含“#”,所以要修改正则表达式
//为了避免版本不一致,各个版本都允许“#”好了,程序处理没有问题
var usernameexp = new RegExp("^[A-Za-z0-9\\._-]{1,20}$");
if (!mainform.username.value.match(usernameexp)){
if (checkvalueDomain()){
return true;
}
alert ("您输入的用户名规则不对,请重新输入");
mainform.username.focus();
return false;
}
}else{
if (1 == 2){
alert ("用户名不能为空,请重新输入!");
mainform.username.focus();
return false;
}else{
if(!confirm("您选用绑定端口方式接入网络吗?")){
return false;
}
}
} return true;
} function checkvalueDomain(){
if (GetStrLen(mainform.username.value)>65 ){
return false;
}
var usernameexp = new RegExp("^[A-Za-z0-9\\._-]{1,20}@[^ \\s@]+$");
if (!mainform.username.value.match(usernameexp)){
return false;
}else{
return true;
} } ifwait=false;
function wait(t){
if(ifwait==true){
return true;
}else{
ifwait=true;
window.setTimeout("ifwait=false;",t);
return false;
}
} function GetStrLen(AStr)
{ var nCount = 0;
var nLenByte = AStr.length;
for(nPos = 0;nPos<nLenByte;nPos ++)
{ if(AStr.charCodeAt(nPos)>256)
nCount = nCount + 2; //中文算两个
else
nCount = nCount + 1;
} return nCount; //返回字节数 }
</script></head>
<body bgcolor="#F2EDE9" onLoad="document.all.mainform.username.focus();" leftmargin="0" topmargin="0" marginwidth="00" marginheight="00">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#339999" width="15%"><a href="help.jsp"><IMG border=0 height=38 src=images/help01.gif width=209></a></td>
<td bgcolor="#339999" width="85%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form id=mainform name=mainform method=post onkeypress="if (event.keyCode==13){if(wait(1000)){return false;} if(checkvalue()) this.submit(); return false; end }" onsubmit="return checkvalue();" action="http://172.31.1.21/secu/webLogin.jsp">
<input type='hidden' name='consumeright' value='0'>
<input type='hidden' name='separatecard' value='0'>
<input type='hidden' name='localIP' value='10.22.32.191'>
<input type='hidden' name='needActiveX' value='1'>
<input type='hidden' name='isPNP' value='0'>
<input type='hidden' name='httpIP' value='210.87.131.194'>
<input type='hidden' name='isProxy' value='0'>
<input type='hidden' name='clienttype' value='1'>
<TBODY>
<tr>
<td width="60" cellpadding=0><IMG height=0 width=10>用户名:</td>
<td width="150">
<input value="xia05307" name=username style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; HEIGHT: 16px; WIDTH: 150px" >
</td>
<td width="80"><IMG height=0 width="30">密 码:</td>
<td width="140">
<input value="096918" name=password type=password style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; HEIGHT: 16px; WIDTH: 120px" >
</td>
<td width="100" align="right"><IMG height=0 width="5" >保存密码:</td>
<td width="120" align="left">
<SELECT name=cookiedate onchange="return useralerm(this.options[this.selectedIndex].value,this.selectedIndex);">
<OPTION value="0" >不保存</OPTION>
<OPTION value="1" >保存一天</OPTION>
<OPTION value="30" >保存一月</OPTION>
<OPTION value="3650" selected>永久保存</OPTION>
</SELECT>
</td>
<td width="110" align="middle"> <A href="连接网络" name="lianjiewangluo" onclick="if (checkvalue()) {mainform.submit();} return false;" ><IMG border=0 height=21 name=images1 src=images/login_d.gif width=64 alt="点击这里进行网络接入认证"></A>
</td>
</TBODY></form></table>
</tr>
</table>
<script>oldCookieDateIndex = mainform.cookiedate.selectedIndex;</script><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<iframe name="content" src="/upload/servicenode/default/weblogin/index.html" frameborder=no scrolling=no height=420px WIDTH=100%>
</iframe>
</td>
</tr>
</table></body></html>
我上网需要输入在IE中输入用户名和密码,然后点击“连接网络”按钮进行登录才可以正常上网。
而我又只在自己电脑上用,想通过什么办法实现自动点击按钮的操作。
用脚本或者VC/VB能实现这样的功能么?请高人指点。
登录页面源文件如下:
<script language='javascript' src="/check.js">
</script> <html>
<head>
<title>我的网上家园</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="coolmenu.css">
<script language="javascript" src="check.js"></script>
<style type="text/css">
<!--
td { font-size: 12px}
-->
</style>
<script language="javascript">
var oldCookieDate = 3650;
var oldCookieDateIndex = 0;
function useralerm(newCookieDate,newIndex) {
var result = true;
if ((oldCookieDate == 0) && (newCookieDate > 0)) {
result = confirm("您选择了在本地保存用户名和密码,这有可能导致您的账号信息被他人窃取。如果您是在公共场合上网,请不要使用此功能。\n您确定要保存账号和密码吗?");
}
if (result) {
oldCookieDate = newCookieDate;
oldCookieDateIndex = newIndex;
}else {
mainform.cookiedate.options[oldCookieDateIndex].selected = true;
}
return result;
}
function checkvalue(){ if (0 == "1") {
mainform.action="http://172.31.1.21/secu/webLogin.jsp";
} mainform.username.value = trim(mainform.username.value);
if (mainform.username.value != null && mainform.username.value !=""){
//深圳的用户名允许包含“#”,所以要修改正则表达式
//为了避免版本不一致,各个版本都允许“#”好了,程序处理没有问题
var usernameexp = new RegExp("^[A-Za-z0-9\\._-]{1,20}$");
if (!mainform.username.value.match(usernameexp)){
if (checkvalueDomain()){
return true;
}
alert ("您输入的用户名规则不对,请重新输入");
mainform.username.focus();
return false;
}
}else{
if (1 == 2){
alert ("用户名不能为空,请重新输入!");
mainform.username.focus();
return false;
}else{
if(!confirm("您选用绑定端口方式接入网络吗?")){
return false;
}
}
} return true;
} function checkvalueDomain(){
if (GetStrLen(mainform.username.value)>65 ){
return false;
}
var usernameexp = new RegExp("^[A-Za-z0-9\\._-]{1,20}@[^ \\s@]+$");
if (!mainform.username.value.match(usernameexp)){
return false;
}else{
return true;
} } ifwait=false;
function wait(t){
if(ifwait==true){
return true;
}else{
ifwait=true;
window.setTimeout("ifwait=false;",t);
return false;
}
} function GetStrLen(AStr)
{ var nCount = 0;
var nLenByte = AStr.length;
for(nPos = 0;nPos<nLenByte;nPos ++)
{ if(AStr.charCodeAt(nPos)>256)
nCount = nCount + 2; //中文算两个
else
nCount = nCount + 1;
} return nCount; //返回字节数 }
</script></head>
<body bgcolor="#F2EDE9" onLoad="document.all.mainform.username.focus();" leftmargin="0" topmargin="0" marginwidth="00" marginheight="00">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#339999" width="15%"><a href="help.jsp"><IMG border=0 height=38 src=images/help01.gif width=209></a></td>
<td bgcolor="#339999" width="85%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form id=mainform name=mainform method=post onkeypress="if (event.keyCode==13){if(wait(1000)){return false;} if(checkvalue()) this.submit(); return false; end }" onsubmit="return checkvalue();" action="http://172.31.1.21/secu/webLogin.jsp">
<input type='hidden' name='consumeright' value='0'>
<input type='hidden' name='separatecard' value='0'>
<input type='hidden' name='localIP' value='10.22.32.191'>
<input type='hidden' name='needActiveX' value='1'>
<input type='hidden' name='isPNP' value='0'>
<input type='hidden' name='httpIP' value='210.87.131.194'>
<input type='hidden' name='isProxy' value='0'>
<input type='hidden' name='clienttype' value='1'>
<TBODY>
<tr>
<td width="60" cellpadding=0><IMG height=0 width=10>用户名:</td>
<td width="150">
<input value="xia05307" name=username style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; HEIGHT: 16px; WIDTH: 150px" >
</td>
<td width="80"><IMG height=0 width="30">密 码:</td>
<td width="140">
<input value="096918" name=password type=password style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; HEIGHT: 16px; WIDTH: 120px" >
</td>
<td width="100" align="right"><IMG height=0 width="5" >保存密码:</td>
<td width="120" align="left">
<SELECT name=cookiedate onchange="return useralerm(this.options[this.selectedIndex].value,this.selectedIndex);">
<OPTION value="0" >不保存</OPTION>
<OPTION value="1" >保存一天</OPTION>
<OPTION value="30" >保存一月</OPTION>
<OPTION value="3650" selected>永久保存</OPTION>
</SELECT>
</td>
<td width="110" align="middle"> <A href="连接网络" name="lianjiewangluo" onclick="if (checkvalue()) {mainform.submit();} return false;" ><IMG border=0 height=21 name=images1 src=images/login_d.gif width=64 alt="点击这里进行网络接入认证"></A>
</td>
</TBODY></form></table>
</tr>
</table>
<script>oldCookieDateIndex = mainform.cookiedate.selectedIndex;</script><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<iframe name="content" src="/upload/servicenode/default/weblogin/index.html" frameborder=no scrolling=no height=420px WIDTH=100%>
</iframe>
</td>
</tr>
</table></body></html>
解决方案 »
- 2008生成release版EXE问题
- 我应该找哪方面的工作呢?
- 进程和线程都设置了优先级,到底按照哪个级别来进行调度?
- 谁发一个好用的 CHyperLink 类.
- CListCtrl的定制功能怎么弄?
- 问一个读数据的问题!
- 我在CDlg中定义了一个OnAccept函数但是,程序但是在程序编译中,死活通不过。为何?
- 请教高手编译错误error LNK2001: unresolved external symbol __imp__PropertySheetA@4
- 关于数据库编程的问题??
- VC大侠,《Essenital C++》
- datagrid 内嵌组合框的定位问题(已经搞了3天了,大家帮帮忙吧,在线等)
- 请问如何使用RichEdit控件打开并显示一个rtf文档?
编写一个名字为window_onload的函数,在里面调用mainform.submit
之前记得设置username 和password
工具->internet选项->内容->自动完成
呵呵,看来我真是笨,说了这么多,还是不知道怎么弄。
To yourhe(大头菜):
我的意思是要做一个东西,加入windows启动项,让系统启动就自动完成登陆,而不是进IE自己点击。IE的自动完成好象不可以吧?用户名密码这些我本来就可以自动保存了。
To jiangsheng(蒋晟.MSMVP2004Jan) :
我现在该怎么做啊?
'''''''''''''''''''''''''''''''''''''''
'自动登录程序
'
''''''''''''''''''''''''''''''''''''''''建立一个WebBrowser的实例
Set myIE = WScript.CreateObject("InternetExplorer.Application")'打开登录的网页
myIE.Navigate "http://172.31.1.21/webLogin.jsp"
myIE.ToolBar = 1
myIE.StatusBar = 1
myIE.Width=1024
myIE.Height = 768
myIE.Left = 0
myIE.Top = 0
myIE.Visible = 1'等待页面所有的对象都载入完毕
While myIE.ReadyState<>4
'just wait, do nonthing here
Wend'填入用户名
myIE.Document.All("username").Value = "用户名"
'填入密码
myIE.Document.All("password").Value = "密码"'登录
myIE.Document.All("mainform").submit()'关闭IE
WScript.Sleep(5000)
myIE.Quit