| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 992 人关注过本帖
标题:求助 不能 自动点击 登录 按钮
只看楼主 加入收藏
yuanyong911
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-3-28
结帖率:0
收藏
已结贴  问题点数:15 回复次数:3 
求助 不能 自动点击 登录 按钮
求助 不能 自动点击 登录 按钮

有个内部 网页 不能 自动提交 求大神帮我看看 多谢

Dim IEList     As New ShellWindows
          Dim browser
          Dim Doc
            
          On Error Resume Next
            
          '遍历当前地浏览器窗口
          For Each browser In IEList
                  '找到需要地IE窗口
                  If browser.Document.Title = "系统登录" Then
                          '获得浏览器地文档对象
                          Set Doc = browser.Document
                           
                          '填写用户名字段
                          Doc.body.All("wcode").Value = zhangsan
                          '填写密码字段
                          Doc.body.All("clearTextPassword").Value = 123456
                          
                          '点击登录按钮
                          Doc.body.All("login()").submit
                          
                          Doc.body.All("login()").onclick
                          
                          Doc.body.All("login()").Click
                          
                          '点击登录按钮
                        browser.Document.parentWindow.execScript "login()"

                  End If
          Next


上面那几种 模拟点击 都不能成功 但 用户名 和密码 可以 填写在上面 就是不能 自动点击 登录



下面 是 网页 源码




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
    <head>
        <title>系统登录</title>
        <page path="/login.jsp"></page>
        <link href="/ccps/resource/themes/login/css/style.css" rel="stylesheet" type="text/css" />
        <script src="/ccps/widget/jquery/jquery-1.6.2.js" type="text/javascript"></script>
        <script src="/ccps/resource/js/md5.js" type="text/javascript"></script>
        <script type="text/javascript">
               function login() {
                   $('#password').val(hex_md5($('#clearTextPassword').val()));
                   if($('#wcode').val() == ''){
                       $('#message').html('为空');
                       $('#wcode').focus();
                       return false;
                   }
                   if($('#password').val() == ''){
                       $('#message').html('空');
                       $('#password').focus();
                       return false;
                   }
                   var params = {              
                       "staff.wcode":$('#wcode').val(),
                       "staff.alias":$('#wcode').val(),
                       "staff.password":$('#password').val()
                   };   
                   $.post("/ccps/validateStaff.action",params,function(msg) {
                               if(msg != null && msg != '0' && msg != ''){
                                   $('#message').html(msg);
                                   return;
                               }
                                     /*if(msg=='01'){
                                      $('#message').html('工号或密码错误');
                                      return;
                                  }else if(msg=='02'){
                                      $('#message').html('工号或密码错误');
                                      return;
                                  }*/
                                  else{
                                      var pwfState = true;
                                      if($('#clearTextPassword').val().length<10){
                                             alert("密码长度不能小于10位");
                                            pwfState = false;
                                        }else if(testPws($('#clearTextPassword').val())){
                                                alert("密码不能包含空格!");
                                              pwfState = false;
                                        }else if($('#clearTextPassword').val().match(/[\u4E00-\u9FA5]/gi)){
                                              alert("密码不能包含汉字!</font>");
                                              pwfState = false;
                                        }else{
                                              var level = 0;
                                              if (/[\d]/.test($('#clearTextPassword').val())){
                                                  level++;
                                              }
                                              if (/[a-z]/.test($('#clearTextPassword').val())||/[A-Z]/.test($('#clearTextPassword').val())) {
                                                  level++;
                                              }
                                              var pattern = new RegExp("[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“'。,、?]") ;
                                              if (pattern.test($('#clearTextPassword').val())) {
                                                  level++;
                                              }
                                              if(level<3){
                                                  alert("密码需同时包含数字、字母和符号!</font>");
                                                  pwfState = false;
                                              }
                                             }
                                      if(pwfState){
                                          $('#loginForm').submit();
                                      }
                                    
                                  }
                               },'text');
                     
               }
               function removeMessage(){
                   $('#message').html('');
               }
               
               $(function(){
                   $.get('/ccps/clear.action?'+new Date().getTime());
                   document.forms['loginForm'].reset();
                   document.onkeydown = function(evt) {
                     evt = evt ? evt : event;
                     if(evt.keyCode==13){
                         login();
                     }
                   }
               });
               
               function testPws(value){
                   //var pattern =/^[a-z0-9_]{6,18}$/;
                   var pattern = /\s+/;
                   var flag = pattern.test(value);
                   if(flag) {
                       return true;
                   } else {
                       return false;
                   }
               }
          </script>
    </head>

    <body >
        <div style="position:fixed; top:0; left:0; bottom:0; right:0; z-index:-1; height:100%"><img src="resource/themes/login/images/login_bj.jpg" style="height:100%; width:100%; border:0; "/></div>
        <div class="login_bj">
            <div class="login_main">
                <div class="login_left"></div>
                <div class="login_right">
                    <form id="loginForm" name="loginForm" action="/ccps/login.action" method="post">
                        <div class="login_width">
                            <div class="login_name">
                                用&nbsp;&nbsp;户&nbsp;&nbsp;名:
                            </div>
                            <div class="login_input">
                                <input name="staff.wcode" maxlength="20" id="wcode" onkeydown="removeMessage()" type="text" class="login_Frame" size="14" />
                            </div>
                        </div>
                        
                        <div class="login_width">
                            <div class="login_name">
                                密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:
                            </div>
                            <div class="login_input">
                                <input name="staff.password" maxlength="18" id="password" onkeydown="removeMessage()" type="hidden" class="login_Frame" size="14" />
                                <input name="clearTextPassword" maxlength="18" id="clearTextPassword" onkeydown="removeMessage()" type="password" class="login_Frame" size="14" />
                            </div>
                        </div>
                        <div class="login_padd">
                            <div class="login_name button">
                                <a href="#" onclick="login()">登录</a>
                            </div>
                            <div class="login_name button">
                                <a href="#" onclick="document.forms['loginForm'].reset()">重置</a>
                            </div>
                        </div>
                    </form>



                    <div class="notice" id="message" style='padding: 0px 0px 0px 32px;color: red;text-align: center; height:30px;'></div>
                    <div style="padding: 0px 0px 0px 32px;"><font color="#82B3EA">建议IE10兼容模式,分辨率:1440*900</font></div>
                </div>
            </div>
    </body>
</html>
搜索更多相关主题的帖子: 登录 html login div class 
2023-08-14 11:19
yuanyong911
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-3-28
收藏
得分:0 
有大神帮我看看吗。多谢。
2023-08-15 11:24
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4947
专家分:30084
注 册:2008-10-15
收藏
得分:15 
                          '点击登录按钮
                        browser.Document.parentWindow.execScript "login();"         加个分号试试
-----------------
找了我以前的代码,有分号的
    jss = "setForm1('ctl00_ContentPlaceHolder1_ddlCategoryId', 6 );"
    obj.parentWindow.execScript jss
--------------
如果还不行,自己写个JS函数,插进去,然后再进行提交。这也是我上面调用的那行代码的执行部分。
'插入JS函数
    Dim obj As Object
    Set obj = Web1.Object.Document
    Dim jss As String
   
    jss = "function setForm1(key,str){document.getElementById(key).value=str;}"
    jss = jss & "function setForm2(key){document.getElementById(key).checked=true;} "
    obj.parentWindow.execScript jss


授人于鱼,不如授人于渔
早已停用QQ了
2023-08-16 08:43
yuanyong911
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-3-28
收藏
得分:0 
以下是引用风吹过b在2023-8-16 08:43:54的发言:

                          '点击登录按钮
                        browser.Document.parentWindow.execScript "login();"         加个分号试试
-----------------
找了我以前的代码,有分号的
    jss = "setForm1('ctl00_ContentPlaceHolder1_ddlCategoryId', 6 );"
    obj.parentWindow.execScript jss
--------------
如果还不行,自己写个JS函数,插进去,然后再进行提交。这也是我上面调用的那行代码的执行部分。
'插入JS函数
    Dim obj As Object
    Set obj = Web1.Object.Document
    Dim jss As String
   
    jss = "function setForm1(key,str){document.getElementById(key).value=str;}"
    jss = jss & "function setForm2(key){document.getElementById(key).checked=true;} "
    obj.parentWindow.execScript jss

  非常感谢 大神 。我试过了 还是没有 反映 不能自动 登录!我再研究研究 多谢
2023-08-17 12:59
快速回复:求助 不能 自动点击 登录 按钮
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022480 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved