Home  >  Q&A  >  body text

javascript - How to actively trigger events using js?


https://login.taobao.com/memb...

After logging into your Taobao account with incorrect passwords multiple times, you will need to hold down the slider and drag it to the right (as shown in the picture). How to use js to implement "hold down the slider and drag it to the left and right"?

三叔三叔2675 days ago1937

reply all(4)I'll reply

  • PHP中文网

    PHP中文网2017-06-22 11:56:01

    This slider is used to detect robots. If you slide it directly with a script, it will judge you as a robot.
    In fact, its essence is not to ask you to slide over, but to detect whether your mouse behavior before, during, and after dragging is consistent with the characteristics of a real person

    reply
    0
  • 学习ing

    学习ing2017-06-22 11:56:01

    There is a createEvent() method in native js, which can actively trigger events. For example:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <p id="aaa" onclick="alert(1)"></p>
        <script type="text/javascript">
            var event = document.createEvent('MouseEvents');
    
            event.initMouseEvent('click', true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0 ,null);
    
            aaa.dispatchEvent(event);
        </script>
    </body>
    </html>
    

    You can change click to mousemove according to your own needs.

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-22 11:56:01


    Look at the picture, the scroll bar is initialized with a span, which is the part you circle, and a p used to display the drag progress.
    If you are only asking about the verification of reaching it
    When dragging the span, the left of the span and the width of p.nc_1__bg change, then try to actively modify these two styles, and set the values ​​​​to 258px, and then Click (or mousedown, mouseup) the span and find that the verification can be completed.

    思路:修改style,然后触发span的click、mousedown、mouseup事件,因为不确定它具体是绑定在up还是down事件中(根据初步操作,应该是绑定在鼠标按下事件中),所以都触发一遍,至于click只是为了防漏.
    代码:
         修改样式:就是修改p的width和span的left为258px,这里略过。
         js:$('#nc_1_wrapper #nc_1_n1z').click();    //触发单击事件
             $('#nc_1_wrapper #nc_1_n1z').mousedown();    //触发鼠标按下事件
             $('#nc_1_wrapper #nc_1_n1z').mouseup();    //触发鼠标弹起事件

    reply
    0
  • 怪我咯

    怪我咯2017-06-22 11:56:01

    In fact, it is a simulation of raising the mouse and you can judge when it is up

    reply
    0
  • Cancelreply